userver: dynamic_config::Snapshot Class Reference
Loading...
Searching...
No Matches
dynamic_config::Snapshot Class Referencefinal

#include <userver/dynamic_config/snapshot.hpp>

Detailed Description

The shared snapshot of dynamic configs. Cheap to copy, even cheaper to move. Thread safe, not updated with new dynamic config values in background (it's a snapshot!).

When a config update comes in via new DocsMap, configs of all the registered types are constructed and stored in Config. After that the DocsMap is dropped.

Config types are automatically registered if they are used somewhere in the program.

Usage example:

namespace myservice::smth {
inline const dynamic_config::Key kMyConfig{"SAMPLE_INTEGER_FROM_RUNTIME_CONFIG", 42};
int Component::DoSomething() const {
// Getting a snapshot of dynamic config.
const auto runtime_config = config_.GetSnapshot();
return runtime_config[kMyConfig];
}
} // namespace myservice::smth

Definition at line 131 of file snapshot.hpp.

Public Member Functions

 Snapshot (const Snapshot &)
 
Snapshotoperator= (const Snapshot &)
 
 Snapshot (Snapshot &&) noexcept
 
Snapshotoperator= (Snapshot &&) noexcept
 
template<typename VariableType >
const VariableType & operator[] (const Key< VariableType > &key) const &
 Used to access individual configs in the type-safe config map.
 
template<typename VariableType >
const VariableType & operator[] (const Key< VariableType > &) &&
 Used to access individual configs in the type-safe config map.
 

Member Function Documentation

◆ operator[]() [1/2]

template<typename VariableType >
const VariableType & dynamic_config::Snapshot::operator[] ( const Key< VariableType > & ) &&

Used to access individual configs in the type-safe config map.

Definition at line 261 of file snapshot.hpp.

◆ operator[]() [2/2]

template<typename VariableType >
const VariableType & dynamic_config::Snapshot::operator[] ( const Key< VariableType > & key) const &

Used to access individual configs in the type-safe config map.

Definition at line 256 of file snapshot.hpp.

Friends And Related Symbol Documentation

◆ Source

friend class Source
friend

Definition at line 161 of file snapshot.hpp.


The documentation for this class was generated from the following file: