Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/envoy/api/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ class Api {
* @return a reference to the TimeSource
*/
virtual TimeSource& timeSource() PURE;

/**
* @return a constant reference to the root Stats::Scope
*/
virtual const Stats::Scope& rootScope() PURE;
};

typedef std::unique_ptr<Api> ApiPtr;
Expand Down
7 changes: 4 additions & 3 deletions source/common/api/api_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
namespace Envoy {
namespace Api {

Impl::Impl(Thread::ThreadFactory& thread_factory, Stats::Store&, Event::TimeSystem& time_system,
Filesystem::Instance& file_system)
: thread_factory_(thread_factory), time_system_(time_system), file_system_(file_system) {}
Impl::Impl(Thread::ThreadFactory& thread_factory, Stats::Store& store,
Event::TimeSystem& time_system, Filesystem::Instance& file_system)
: thread_factory_(thread_factory), store_(store), time_system_(time_system),
file_system_(file_system) {}

Event::DispatcherPtr Impl::allocateDispatcher() {
return std::make_unique<Event::DispatcherImpl>(*this, time_system_);
Expand Down
4 changes: 3 additions & 1 deletion source/common/api/api_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Api {
*/
class Impl : public Api {
public:
Impl(Thread::ThreadFactory& thread_factory, Stats::Store&, Event::TimeSystem& time_system,
Impl(Thread::ThreadFactory& thread_factory, Stats::Store& store, Event::TimeSystem& time_system,
Filesystem::Instance& file_system);

// Api::Api
Expand All @@ -25,9 +25,11 @@ class Impl : public Api {
Thread::ThreadFactory& threadFactory() override { return thread_factory_; }
Filesystem::Instance& fileSystem() override { return file_system_; }
TimeSource& timeSource() override { return time_system_; }
const Stats::Scope& rootScope() override { return store_; }

private:
Thread::ThreadFactory& thread_factory_;
Stats::Store& store_;
Event::TimeSystem& time_system_;
Filesystem::Instance& file_system_;
};
Expand Down
5 changes: 4 additions & 1 deletion test/mocks/api/mocks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ using testing::Return;
namespace Envoy {
namespace Api {

MockApi::MockApi() { ON_CALL(*this, fileSystem()).WillByDefault(ReturnRef(file_system_)); }
MockApi::MockApi() {
ON_CALL(*this, fileSystem()).WillByDefault(ReturnRef(file_system_));
ON_CALL(*this, rootScope()).WillByDefault(ReturnRef(stats_store_));
}

MockApi::~MockApi() {}

Expand Down
1 change: 1 addition & 0 deletions test/mocks/api/mocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class MockApi : public Api {
Event::TimeSystem&));
MOCK_METHOD0(fileSystem, Filesystem::Instance&());
MOCK_METHOD0(threadFactory, Thread::ThreadFactory&());
MOCK_METHOD0(rootScope, const Stats::Scope&());

testing::NiceMock<Filesystem::MockInstance> file_system_;
Event::GlobalTimeSystem time_system_;
Expand Down