#include <userver/dynamic_config/snapshot.hpp>
A config key is a unique identifier for a config variable.
Definition at line 67 of file snapshot.hpp.
Public Types | |
| using | VariableType = Variable |
| The type of the parsed config variable. | |
| using | JsonParser = Variable (*)(const formats::json::Value&) |
| using | DocsMapParser = Variable (*)(const DocsMap&) |
Public Member Functions | |
| Key (std::string_view name, const VariableType &default_value) | |
| The constructor for a trivial VariableType, e.g. bool, integer, double, string. The default is passed by value. | |
| Key (std::string_view name, const VariableType &default_value, SchemaHash schema_hash) | |
| The constructor for a trivial VariableType with schema metadata. | |
| Key (std::string_view name, DefaultAsJsonString default_json) | |
| The constructor for a non-trivial VariableType. The default is passed as a JSON string. | |
| Key (std::string_view name, DefaultAsJsonString default_json, SchemaHash schema_hash) | |
| The constructor for a non-trivial VariableType with schema metadata. | |
| Key (std::string_view name, JsonParser parser, DefaultAsJsonString default_json) | |
| The constructor that provides a special parser from JSON. | |
| Key (std::string_view name, JsonParser parser, DefaultAsJsonString default_json, SchemaHash schema_hash) | |
| The constructor with a custom JSON parser and schema metadata. | |
| template<std::size_t N> | |
| Key (DocsMapParser parser, const ConfigDefault(&default_json_map)[N]) | |
| The constructor that parses multiple JSON config items into a single C++ object. | |
| Key (ConstantConfig, VariableType value) | |
| Creates a config that always has the same value. | |
| Key (const Key &) noexcept=delete | |
| Key & | operator= (const Key &) noexcept=delete |
| std::string_view | GetName () const noexcept |
| VariableType | Parse (const DocsMap &docs_map) const |
| template<typename Variable> | |
| Key (impl::InternalTag, std::string_view name) | |
| template<typename Variable> | |
| Key (impl::InternalTag, DocsMapParser parser) | |
| using dynamic_config::Key< Variable >::DocsMapParser = Variable (*)(const DocsMap&) |
Definition at line 73 of file snapshot.hpp.
| using dynamic_config::Key< Variable >::JsonParser = Variable (*)(const formats::json::Value&) |
Definition at line 72 of file snapshot.hpp.
| using dynamic_config::Key< Variable >::VariableType = Variable |
The type of the parsed config variable.
Definition at line 70 of file snapshot.hpp.
| dynamic_config::Key< Variable >::Key | ( | std::string_view | name, |
| const VariableType & | default_value ) |
The constructor for a trivial VariableType, e.g. bool, integer, double, string. The default is passed by value.
Usage example:
Definition at line 222 of file snapshot.hpp.
| dynamic_config::Key< Variable >::Key | ( | std::string_view | name, |
| const VariableType & | default_value, | ||
| SchemaHash | schema_hash ) |
The constructor for a trivial VariableType with schema metadata.
| schema_hash | Opaque schema hash. |
Definition at line 227 of file snapshot.hpp.
| dynamic_config::Key< Variable >::Key | ( | std::string_view | name, |
| DefaultAsJsonString | default_json ) |
The constructor for a non-trivial VariableType. The default is passed as a JSON string.
Uses formats::json::Value Parse customization point function to parse VariableType.
Usage example:
Definition at line 239 of file snapshot.hpp.
| dynamic_config::Key< Variable >::Key | ( | std::string_view | name, |
| DefaultAsJsonString | default_json, | ||
| SchemaHash | schema_hash ) |
The constructor for a non-trivial VariableType with schema metadata.
| schema_hash | Opaque schema hash. |
Definition at line 244 of file snapshot.hpp.
| dynamic_config::Key< Variable >::Key | ( | std::string_view | name, |
| JsonParser | parser, | ||
| DefaultAsJsonString | default_json ) |
The constructor that provides a special parser from JSON.
Can be used when generic Parse is not applicable. Sometimes used to add validation, e.g. minimum, maximum, string pattern, etc.
Definition at line 256 of file snapshot.hpp.
| dynamic_config::Key< Variable >::Key | ( | std::string_view | name, |
| JsonParser | parser, | ||
| DefaultAsJsonString | default_json, | ||
| SchemaHash | schema_hash ) |
The constructor with a custom JSON parser and schema metadata.
| name | config variable name |
| parser | custom JSON parser for the variable |
| default_json | default value as a JSON string |
| schema_hash | Opaque schema hash. Stored in the global registry and retrievable via dynamic_config::impl::GetRegisteredConfigsMeta() as dynamic_config::RegisteredConfigMeta::schema_hash. |
Definition at line 261 of file snapshot.hpp.
| dynamic_config::Key< Variable >::Key | ( | DocsMapParser | parser, |
| const ConfigDefault(&) | default_json_map[N] ) |
The constructor that parses multiple JSON config items into a single C++ object.
To register schema metadata for the JSON config items, pass the generated variable_namespace::GetSchemaHash() to each ConfigDefault.
Definition at line 274 of file snapshot.hpp.
| dynamic_config::Key< Variable >::Key | ( | ConstantConfig | , |
| VariableType | value ) |
Creates a config that always has the same value.
Definition at line 293 of file snapshot.hpp.
| dynamic_config::Key< Variable >::Key | ( | impl::InternalTag | , |
| std::string_view | name ) |
Definition at line 298 of file snapshot.hpp.
| dynamic_config::Key< Variable >::Key | ( | impl::InternalTag | , |
| DocsMapParser | parser ) |
Definition at line 308 of file snapshot.hpp.
|
noexcept |
Definition at line 316 of file snapshot.hpp.
| VariableType dynamic_config::Key< VariableType >::Parse | ( | const DocsMap & | docs_map | ) | const |
Parses the config. Useful only in some very niche scenarios. The config value should be typically be retrieved from dynamic_config::Snapshot, which is obtained from components::DynamicConfig in production or from dynamic_config::StorageMock in unit tests.
Definition at line 321 of file snapshot.hpp.