Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions include/envoy/runtime/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@ class Loader {
virtual void initialize(Upstream::ClusterManager& cm) PURE;

/**
* @return Snapshot& the current snapshot. This reference is safe to use for the duration of
* @return const Snapshot& the current snapshot. This reference is safe to use for the duration of
* the calling routine, but may be overwritten on a future event loop cycle so should be
* fetched again when needed.
*/
virtual Snapshot& snapshot() PURE;
virtual const Snapshot& snapshot() PURE;

/**
* Merge the given map of key-value pairs into the runtime's state. To remove a previous merge for
Expand Down
2 changes: 1 addition & 1 deletion source/common/runtime/runtime_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ void LoaderImpl::loadNewSnapshot() {
});
}

Snapshot& LoaderImpl::snapshot() { return tls_->getTyped<Snapshot>(); }
const Snapshot& LoaderImpl::snapshot() { return tls_->getTyped<Snapshot>(); }

void LoaderImpl::mergeValues(const std::unordered_map<std::string, std::string>& values) {
if (admin_layer_ == nullptr) {
Expand Down
2 changes: 1 addition & 1 deletion source/common/runtime/runtime_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class LoaderImpl : public Loader, Logger::Loggable<Logger::Id::runtime> {

// Runtime::Loader
void initialize(Upstream::ClusterManager& cm) override;
Snapshot& snapshot() override;
const Snapshot& snapshot() override;
void mergeValues(const std::unordered_map<std::string, std::string>& values) override;

private:
Expand Down
4 changes: 2 additions & 2 deletions test/common/runtime/runtime_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ TEST_F(DiskLoaderImplTest, All) {
EXPECT_EQ(123UL, loader_->snapshot().getInteger("file4", 1));

bool value;
SnapshotImpl* snapshot = reinterpret_cast<SnapshotImpl*>(&loader_->snapshot());
const SnapshotImpl* snapshot = reinterpret_cast<const SnapshotImpl*>(&loader_->snapshot());

// Validate that the layer name is set properly for static layers.
EXPECT_EQ("base", snapshot->getLayers()[0]->name());
Expand Down Expand Up @@ -538,7 +538,7 @@ TEST_F(StaticLoaderImplTest, ProtoParsing) {

// Boolean getting.
bool value;
SnapshotImpl* snapshot = reinterpret_cast<SnapshotImpl*>(&loader_->snapshot());
const SnapshotImpl* snapshot = reinterpret_cast<const SnapshotImpl*>(&loader_->snapshot());

EXPECT_EQ(true, snapshot->getBoolean("file11", value));
EXPECT_EQ(true, value);
Expand Down
2 changes: 1 addition & 1 deletion test/mocks/runtime/mocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class MockLoader : public Loader {
~MockLoader() override;

MOCK_METHOD1(initialize, void(Upstream::ClusterManager& cm));
MOCK_METHOD0(snapshot, Snapshot&());
MOCK_METHOD0(snapshot, const Snapshot&());
MOCK_METHOD1(mergeValues, void(const std::unordered_map<std::string, std::string>&));

testing::NiceMock<MockSnapshot> snapshot_;
Expand Down