Github   Telegram
No Matches
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
components::DynamicConfig Class Referencefinal

Component that stores the runtime config. More...

#include <userver/dynamic_config/storage/component.hpp>

+ Inheritance diagram for components::DynamicConfig:
+ Collaboration diagram for components::DynamicConfig:


class  NoblockSubscriber
 Allows to subscribe to DynamicConfig updates without waiting for the first update to complete. Primarily intended for internal use. More...

Public Member Functions

 DynamicConfig (const ComponentConfig &, const ComponentContext &)
dynamic_config::Source GetSource ()
- Public Member Functions inherited from components::DynamicConfigUpdatesSinkBase
 DynamicConfigUpdatesSinkBase (const components::ComponentConfig &, const components::ComponentContext &)
virtual void SetConfig (std::string_view updater, dynamic_config::DocsMap &&config)=0
virtual void SetConfig (std::string_view updater, const dynamic_config::DocsMap &config)
virtual void NotifyLoadingFailed (std::string_view updater, std::string_view error)=0
- Public Member Functions inherited from components::LoggableComponentBase
 LoggableComponentBase (const ComponentConfig &, const ComponentContext &)
 LoggableComponentBase (LoggableComponentBase &&)=delete
 LoggableComponentBase (const LoggableComponentBase &)=delete
 ~LoggableComponentBase () override=default
ComponentHealth GetComponentHealth () const override
void OnLoadingCancelled () override
void OnAllComponentsLoaded () override
void OnAllComponentsAreStopping () override

Static Public Member Functions

static yaml_config::Schema GetStaticConfigSchema ()
- Static Public Member Functions inherited from components::LoggableComponentBase
static yaml_config::Schema GetStaticConfigSchema ()

Static Public Attributes

static constexpr std::string_view kName = "dynamic-config"
 The default name of components::DynamicConfig. More...

Detailed Description

Component that stores the runtime config.

Static options:

Name Description Default value
fs-cache-path path to the file to read and dump a config cache; set to empty string to disable reading and dumping configs to FS -
fs-task-processor name of the task processor to run the blocking file write operations -

Static configuration example:

# yaml
fs-cache-path: $runtime_config_path
fs-task-processor: fs-task-processor

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 41 of file component.hpp.

Member Function Documentation

◆ GetSource()

dynamic_config::Source components::DynamicConfig::GetSource ( )

Use dynamic_config::Source to get up-to-date config values, or to do something special on config updates


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