userver: components::DynamicConfig Class Reference
⚠️ This is the documentation for an old userver version. Click here to switch to the latest version.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts

Component that stores the runtime config. More...

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

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

Classes

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 &)
 
- 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.
 

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:

    dynamic-config:
      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
Examples
components/component_sample_test.cpp.

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

Examples
components/component_sample_test.cpp.

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