Github   Telegram
Loading...
Searching...
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:

Classes

class  NoblockSubscriber
 Allows to subscribe to DynamicConfig updates without waiting for the first update to complete. Primarily intended for internal use. More...
 
class  Updater
 Class that provides update functionality for the config. More...
 

Public Member Functions

 DynamicConfig (const ComponentConfig &, const ComponentContext &)
 
dynamic_config::Source GetSource ()
 
- 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"
 

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
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 43 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.

Member Data Documentation

◆ kName

constexpr std::string_view components::DynamicConfig::kName = "dynamic-config"
staticconstexpr

Definition at line 45 of file component.hpp.


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