Github   Telegram
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
components::DynamicConfigClientUpdater Class Reference

Component that does a periodic update of runtime configs. More...

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

+ Inheritance diagram for components::DynamicConfigClientUpdater:
+ Collaboration diagram for components::DynamicConfigClientUpdater:

Public Member Functions

 DynamicConfigClientUpdater (const ComponentConfig &, const ComponentContext &)
 
dynamic_config::AdditionalKeysToken SetAdditionalKeys (std::vector< std::string > keys)
 
void Update (cache::UpdateType update_type, const std::chrono::system_clock::time_point &last_update, const std::chrono::system_clock::time_point &now, cache::UpdateStatisticsScope &) override
 Must override in a subclass. More...
 
- Public Member Functions inherited from components::CachingComponentBase< dynamic_config::DocsMap >
 CachingComponentBase (const ComponentConfig &config, const ComponentContext &)
 
utils::SharedReadablePtr< dynamic_config::DocsMapGet () const
 
utils::SharedReadablePtr< dynamic_config::DocsMapGetUnsafe () const
 
concurrent::AsyncEventSubscriberScope UpdateAndListen (Class *obj, std::string name, void(Class::*func)(const std::shared_ptr< const dynamic_config::DocsMap > &))
 
concurrent::AsyncEventChannel< const std::shared_ptr< const dynamic_config::DocsMap > & > & GetEventChannel ()
 
- 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::CachingComponentBase< dynamic_config::DocsMap >
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-client-updater"
 

Additional Inherited Members

- Public Types inherited from components::CachingComponentBase< dynamic_config::DocsMap >
using DataType = dynamic_config::DocsMap
 
- Protected Types inherited from cache::CacheUpdateTrait
enum class  Flag {
  kNone = 0 ,
  kNoFirstUpdate = 1 << 0
}
 Periodic update flags. More...
 
- Protected Member Functions inherited from components::CachingComponentBase< dynamic_config::DocsMap >
void Set (std::unique_ptr< const dynamic_config::DocsMap > value_ptr)
 
void Set (dynamic_config::DocsMap &&value)
 
void Emplace (Args &&... args)
 
void Clear ()
 
virtual bool MayReturnNull () const
 
virtual void WriteContents (dump::Writer &writer, const dynamic_config::DocsMap &contents) const
 
virtual std::unique_ptr< const dynamic_config::DocsMapReadContents (dump::Reader &reader) const
 
- Protected Member Functions inherited from cache::CacheUpdateTrait
AllowedUpdateTypes GetAllowedUpdateTypes () const
 Update types configured for the cache.
 
void StartPeriodicUpdates (utils::Flags< Flag > flags={})
 Starts periodic updates.
 
void StopPeriodicUpdates ()
 Stops periodic updates. More...
 
void AssertPeriodicUpdateStarted ()
 
void OnCacheModified ()
 
virtual void Update (UpdateType type, const std::chrono::system_clock::time_point &last_update, const std::chrono::system_clock::time_point &now, UpdateStatisticsScope &stats_scope)=0
 Must override in a subclass. More...
 
 CacheUpdateTrait (CacheUpdateTrait &&)=delete
 
CacheUpdateTraitoperator= (CacheUpdateTrait &&)=delete
 
void Update (UpdateType update_type)
 Forces a cache update of specified type. More...
 
const std::string & Name () const
 

Detailed Description

Component that does a periodic update of runtime configs.

Optional update event deduplication

Config update types to deduplicate. If enabled, JSON of the whole config is compared to the previous one; if same, no config update event is sent to the subscribers of dynamic_config::Source (OnConfigUpdate functions).

deduplicate-update-types static config option specifies the update types of the config cache, for which event deduplication should be performed. Possible values:

Full updates will always send an event unless deduplicated. Incremental updates may send an extra event for some config service implementations.

Note: This is not a silver bullet against extra events, because the events will be sent to every dynamic config subscriber if any part of the config has updated, not if the interesting part has updated.

Static options:

Name Description Default value
store-enabled store the retrieved values into the components::dynamicConfig -
load-only-my-values request from the client only the values used by this service -
fallback-path a path to the fallback config to load the required config names from it -
fs-task-processor name of the task processor to run the blocking file write operations -
deduplicate-update-types update types for best-effort update event deduplication, see above full-and-incremental

See also the options for components::CachingComponentBase.

Static configuration example:

# yaml
dynamic-config-client-updater:
store-enabled: true
load-only-my-values: true
fallback-path: $runtime_config_path
fallback-path#fallback: /some/path/to/runtime_config.json
fs-task-processor: fs-task-processor
# options from components::CachingComponentBase
update-types: full-and-incremental
update-interval: 5s
update-jitter: 2s
full-update-interval: 5m
first-update-fail-ok: true
config-settings: true
additional-cleanup-interval: 5m
testsuite-force-periodic-update: true

Definition at line 70 of file component.hpp.

Member Function Documentation

◆ Update()

void components::DynamicConfigClientUpdater::Update ( cache::UpdateType  type,
const std::chrono::system_clock::time_point &  last_update,
const std::chrono::system_clock::time_point &  now,
cache::UpdateStatisticsScope stats_scope 
)
overridevirtual

Must override in a subclass.

Note
Must update statistics using stats_scope, and call CachingComponentBase::Set if the cached data has changed
Exceptions
Anystd::exception on error

Implements cache::CacheUpdateTrait.

Member Data Documentation

◆ kName

constexpr std::string_view components::DynamicConfigClientUpdater::kName = "dynamic-config-client-updater"
staticconstexpr

Definition at line 73 of file component.hpp.


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