#include <userver/dynamic_config/updater/component.hpp>
Component that does a periodic update of runtime configs.
Note that the service with dynamic config update component and without configs cache requires successful update to start. See dynamic_config_fallback for details and explanation.
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:
none (the default)only-fullonly-incrementalfull-and-incrementalFull 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.
| Name | Description | Default value |
|---|---|---|
| updates-sink | Name of the component derived from components::DynamicConfigUpdatesSinkBase to be used for storing received updates. | dynamic-config |
| store-enabled | Store the retrieved values into the updates sink component. | true |
| load-only-my-values | Request from the client only the values used by this service. | true |
| deduplicate-update-types | Config update types for best-effort deduplication. Possible values: none, only-full, only-incremental, full-and-incremental. | full-and-incremental |
Options inherited from components::CachingComponentBase :
| Name | Description | Default value |
|---|---|---|
| update-types | Specifies whether incremental and/or full updates are used. Possible values: full-and-incremental, only-full, only-incremental. | – |
| update-interval | (required) interval between Update invocations. | – |
| update-jitter | Max. amount of time by which update-interval may be adjusted for requests dispersal. | update_interval / 10 |
| updates-enabled | If false, cache updates are disabled (except for the first one if !first-update-fail-ok). | true |
| full-update-interval | Interval between full updates. | – |
| full-update-jitter | Max. amount of time by which full-update-interval may be adjusted for requests dispersal. | full-update-interval / 10 |
| exception-interval | Sleep interval after an unhandled exception. | update_interval |
| first-update-fail-ok | Whether first update failure is non-fatal. | false |
| task-processor | The name of the TaskProcessor for running DoWork. | main-task-processor |
| config-settings | Enables dynamic reconfiguration with CacheConfigSet. | true |
| additional-cleanup-interval | How often to run background RCU garbage collector. | 10 seconds |
| is-strong-period | Whether to include Update execution time in update-interval. | false |
| has-pre-assign-check | Enables the check before changing the value in the cache, by default it is the check that the new value is not empty. | false |
| testsuite-force-periodic-update | Override testsuite-periodic-update-enabled in TestsuiteSupport component config. | – |
| failed-updates-before-expiration | The number of consecutive failed updates for data expiration. | – |
| alert-on-failing-to-update-times | Fire an alert if the cache update failed specified amount of times in a row. If zero - alerts are disabled. Value from dynamic config takes priority over static. | 0 |
| safe-data-lifetime | Enables awaiting data destructors in the component's destructor. Can be set to false if the stored data does not refer to the component and its dependencies. | true |
| dump | Manages cache behavior after dump load. | – |
| dump.first-update-mode | Behavior of update after successful load from dump. skip - after successful load from dump, do nothing; required - make a synchronous update of type first-update-type, stop the service on failure; best-effort - make a synchronous update of type first-update-type, keep working and use data from dump on failure. Possible values: skip, required, best-effort. | skip |
| dump.first-update-type | Update type after successful load from dump. Possible values: full, incremental, incremental-then-async-full. | full |
Options inherited from components::ComponentBase :
| Name | Description | Default value |
|---|---|---|
| load-enabled | Set to false to disable loading of the component. | true |
See also the options for components::CachingComponentBase.
Definition at line 70 of file component.hpp.
Inheritance diagram for components::DynamicConfigClientUpdater:Public Types | |
| using | DataType |
Public Member Functions | |
| DynamicConfigClientUpdater (const ComponentConfig &, const ComponentContext &) | |
| dynamic_config::AdditionalKeysToken | SetAdditionalKeys (std::vector< std::string > keys) |
| const std::string & | Name () const |
| const std::string & | Name () const |
| void | InvalidateAsync (UpdateType update_type) |
| Non-blocking forced cache update of specified type. | |
| void | InvalidateAsync (UpdateType update_type) |
| Non-blocking forced cache update of specified type. | |
| void | InvalidateAsync (UpdateType update_type) |
| Non-blocking forced cache update of specified type. | |
| utils::SharedReadablePtr< dynamic_config::DocsMap > | Get () const final |
| utils::SharedReadablePtr< dynamic_config::DocsMap > | GetUnsafe () 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 () |
| ComponentHealth | GetComponentHealth () const override |
| void | OnLoadingCancelled () override |
| void | OnAllComponentsAreStopping () override |
| void | UpdateSyncDebug (UpdateType update_type) |
| Forces a cache update of specified type. | |
Static Public Member Functions | |
| static yaml_config::Schema | GetStaticConfigSchema () |
Static Public Attributes | |
| static constexpr std::string_view | kName = "dynamic-config-client-updater" |
| The default name of components::DynamicConfigClientUpdater. | |
Protected Types | |
| using | LoggableComponentBase |
| enum | Flag |
| Periodic update flags. More... | |
Protected Member Functions | |
| void | Set (std::unique_ptr< const dynamic_config::DocsMap > value_ptr) |
| void | Set (dynamic_config::DocsMap &&value) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | Attach (const std::shared_ptr< const dynamic_config::DocsMap > &value_ptr) |
| void | Emplace (Args &&... args) |
| void | Clear () |
| Clears the content of the cache by string a default constructed T. | |
| virtual bool | MayReturnNull () const |
Whether Get is expected to return nullptr. | |
| virtual void | PreAssignCheck (const dynamic_config::DocsMap *old_value_ptr, const dynamic_config::DocsMap *new_value_ptr) const |
| If the option has-pre-assign-check is set true in static config, this function is called before assigning the new value to the cache. | |
| void | UpdateSyncDebug (UpdateType update_type) |
| Forces a cache update of specified type. | |
| AllowedUpdateTypes | GetAllowedUpdateTypes () const |
| Update types configured for the cache. | |
| void | StartPeriodicUpdates (utils::Flags< Flag > flags={}) |
| Starts periodic updates. | |
| void | StartPeriodicUpdates (utils::Flags< Flag > flags={}) |
| Starts periodic updates. | |
| void | StopPeriodicUpdates () |
| Stops periodic updates. | |
| void | AssertPeriodicUpdateStarted () |
| void | AssertPeriodicUpdateStopped () |
| void | OnCacheModified () |
| virtual void | WriteContents (dump::Writer &writer, const dynamic_config::DocsMap &contents) const |
| virtual std::unique_ptr< const dynamic_config::DocsMap > | ReadContents (dump::Reader &reader) const |
|
inherited |
Definition at line 145 of file caching_component_base.hpp.
|
protectedinherited |
Definition at line 67 of file component_base.hpp.
|
strongprotectedinherited |
Periodic update flags.
Definition at line 61 of file cache_update_trait.hpp.
|
protectedinherited |
Attach the value of cache. As a result the Get() member function starts returning the value passed into this function after the Update() finishes. Does not take over into sole ownership. Do not use unless absolutely necessary. The object must be strictly thread-safe.
Definition at line 186 of file caching_component_base.hpp.
|
protectedinherited |
Clears the content of the cache by string a default constructed T.
Definition at line 193 of file caching_component_base.hpp.
|
protectedinherited |
Definition at line 190 of file caching_component_base.hpp.
|
finalvirtualinherited |
nullptr if and only if MayReturnNull returns true. | cache::EmptyCacheError | if the contents are nullptr, and MayReturnNull returns false (which is the default behavior). |
Implements cache::DataProvider< dynamic_config::DocsMap >.
Definition at line 151 of file caching_component_base.hpp.
|
inlineoverrideinherited |
Override this function to inform the world of the state of your component.
Definition at line 35 of file component_base.hpp.
|
inherited |
Definition at line 165 of file caching_component_base.hpp.
|
inherited |
MayReturnNull. Definition at line 154 of file caching_component_base.hpp.
|
inherited |
Non-blocking forced cache update of specified type.
|
inherited |
Non-blocking forced cache update of specified type.
|
inherited |
Non-blocking forced cache update of specified type.
|
protectedvirtualinherited |
Whether Get is expected to return nullptr.
Definition at line 196 of file caching_component_base.hpp.
|
inherited |
|
inherited |
|
inlineoverrideinherited |
Component may use this function to stop doing work before the stop of the components that depend on it.
Base components may override it and make final to do some work before the derived object constructor is called. Don't use it otherwise.
Definition at line 58 of file component_base.hpp.
|
protectedinherited |
Called in CachingComponentBase::Set during update to indicate that the cached data has been modified
|
inlineoverrideinherited |
Called once if the creation of any other component failed. If the current component expects some other component to take any action with the current component, this call is a signal that such action may never happen due to components loading was cancelled. Application components might not want to override it.
Definition at line 42 of file component_base.hpp.
|
protectedvirtualinherited |
If the option has-pre-assign-check is set true in static config, this function is called before assigning the new value to the cache.
Definition at line 208 of file caching_component_base.hpp.
|
protectedvirtualinherited |
Definition at line 202 of file caching_component_base.hpp.
|
protectedinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 178 of file caching_component_base.hpp.
|
protectedinherited |
Sets the new value of cache. As a result the Get() member function starts returning the value passed into this function after the Update() finishes.
Definition at line 175 of file caching_component_base.hpp.
|
protectedinherited |
Stops periodic updates.
|
inherited |
Subscribes to cache updates using a member function. Also immediately invokes the function with the current cache contents.
Definition at line 159 of file caching_component_base.hpp.
|
inherited |
Forces a cache update of specified type.
| If | Update throws |
|
inherited |
Forces a cache update of specified type.
| If | Update throws |
|
protectedvirtualinherited |
Override to use custom serialization for cache dumps
Definition at line 200 of file caching_component_base.hpp.