userver: userver/dynamic_config/updates_sink/find.hpp Source File
⚠️ 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
find.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/dynamic_config/updates_sink/find.hpp
4/// @brief Function for retrieving dynamic config updates sink specified in the
5/// static config.
6
7#include <type_traits>
8
9#include <userver/components/component_fwd.hpp>
10#include <userver/dynamic_config/fwd.hpp>
11
12USERVER_NAMESPACE_BEGIN
13
14namespace dynamic_config {
15
16namespace impl {
17
19 const components::ComponentConfig&, const components::ComponentContext&);
20
21inline bool has_updater = true;
22
23template <typename Dummy = void>
24struct RegisterUpdater {
25 static_assert(std::is_same_v<Dummy, void>);
26 static inline const bool done = ((has_updater = true), true);
27};
28
29} // namespace impl
30
31/// @brief Returns component to which incoming dynamic config updates should be
32/// forwarded.
33///
34/// Component to be used as an updates sink is determined by the `updates-sink`
35/// static config field. If this field is not set, then
36/// components::DynamicConfig is used as a default sink.
37///
38/// @warning Can only be called from other component's constructor in a task
39/// where that constructor was called. May block and asynchronously wait for the
40/// creation of the requested component.
41///
42/// @note It is illegal to use the same updates sink from several components.
43template <typename Dummy = void>
45 const components::ComponentConfig& config,
46 const components::ComponentContext& context) {
47 (void)impl::RegisterUpdater<Dummy>::done;
48 return impl::FindUpdatesSink(config, context);
49}
50
51} // namespace dynamic_config
52
53USERVER_NAMESPACE_END