userver: components::DynamicConfig::NoblockSubscriber Class Reference
Loading...
Searching...
No Matches
components::DynamicConfig::NoblockSubscriber Class Referencefinal

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

Detailed Description

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

Definition at line 119 of file component.hpp.

Public Member Functions

 NoblockSubscriber (DynamicConfig &config_component) noexcept
 NoblockSubscriber (NoblockSubscriber &&)=delete
NoblockSubscriber & operator= (NoblockSubscriber &&)=delete
template<typename Class>
void UpdateIfHasConfigAndListen (utils::ResourceScopeStorage &scopes, Class *obj, std::string_view name, void(Class::*func)(const dynamic_config::Diff &diff))
 Subscribes to dynamic-config updates without waiting for the first update.

Member Function Documentation

◆ UpdateIfHasConfigAndListen()

template<typename Class>
void components::DynamicConfig::NoblockSubscriber::UpdateIfHasConfigAndListen ( utils::ResourceScopeStorage & scopes,
Class * obj,
std::string_view name,
void(Class::* func )(const dynamic_config::Diff &diff) )
inline

Subscribes to dynamic-config updates without waiting for the first update.

If a config snapshot is already loaded when the scope is entered, constructs dynamic_config::Diff from std::nullopt and the current snapshot and invokes the listener. Otherwise only subscribes; the listener is first invoked when a snapshot arrives.

Further updates are delivered after utils::ResourceScopeStorage::AfterConstruction. Unsubscribe runs in utils::ResourceScopeStorage::BeforeDestruction.

Note
Callbacks occur in full accordance with components::DynamicConfigClientUpdater options.
Warning
In debug mode the last notification for any subscriber will be called with std::nullopt and current config snapshot.
Parameters
scopesstorage that owns the subscription lifetime. In a component constructor pass context.Scopes() or components::GetResourceScopes.
objthe subscriber, which is the owner of the listener method, and is also used as the unique identifier of the subscription
namethe name of the subscriber, for diagnostic purposes
functhe listener method, named OnConfigUpdate by convention.
See also
based on concurrent::AsyncEventSource engine
dynamic_config::Diff

Definition at line 153 of file component.hpp.


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