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

The storage for a snapshot of configs. More...

#include <userver/dynamic_config/snapshot.hpp>

Public Member Functions

 Snapshot (const Snapshot &)
 
Snapshotoperator= (const Snapshot &)
 
 Snapshot (Snapshot &&) noexcept
 
Snapshotoperator= (Snapshot &&) noexcept
 
template<typename Key >
const VariableOfKey< Key > & operator[] (Key key) const &
 Used to access individual configs in the type-safe config map.
 
template<typename Key >
const VariableOfKey< Key > & operator[] (Key) &&
 Used to access individual configs in the type-safe config map.
 
template<typename T >
const T & Get () const &
 Deprecated, use config[key] instead.
 
template<typename T >
const T & Get () &&
 Deprecated, use config[key] instead.
 

Friends

class Source
 

Detailed Description

The storage for a snapshot of configs.

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 accessed with Get somewhere in the program.

Usage example:

namespace myservice::smth {
namespace {
int ParseRuntimeCfg(const dynamic_config::DocsMap& docs_map) {
return docs_map.Get("SAMPLE_INTEGER_FROM_RUNTIME_CONFIG").As<int>();
}
} // namespace
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 42 of file snapshot.hpp.

Member Function Documentation

◆ Get() [1/2]

template<typename T >
const T & dynamic_config::Snapshot::Get ( ) &&
inline

Deprecated, use config[key] instead.

Definition at line 72 of file snapshot.hpp.

◆ Get() [2/2]

template<typename T >
const T & dynamic_config::Snapshot::Get ( ) const &
inline

Deprecated, use config[key] instead.

Definition at line 66 of file snapshot.hpp.

◆ operator[]() [1/2]

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

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

Definition at line 54 of file snapshot.hpp.

◆ operator[]() [2/2]

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

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

Definition at line 60 of file snapshot.hpp.

Friends And Related Symbol Documentation

◆ Source

friend class Source
friend

Definition at line 82 of file snapshot.hpp.


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