userver: userver/dynamic_config/client/component.hpp Source File
Loading...
Searching...
No Matches
component.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/dynamic_config/client/component.hpp
4/// @brief @copybrief components::DynamicConfigClient
5
6#include <userver/components/component_base.hpp>
7#include <userver/dynamic_config/client/client.hpp>
8
9USERVER_NAMESPACE_BEGIN
10
11namespace components {
12
13/// @ingroup userver_components
14///
15/// @brief Component that starts a clients::dynamic_config::Client client.
16///
17/// Returned references to clients::dynamic_config::Client live for a lifetime
18/// of the component and are safe for concurrent use.
19///
20/// The component must be configured in service config.
21///
22/// ## Static options of components::DynamicConfigClient :
23/// @include{doc} scripts/docs/en/components_schema/core/src/dynamic_config/client/component.md
24///
25/// Options inherited from @ref components::ComponentBase :
26/// @include{doc} scripts/docs/en/components_schema/core/src/components/impl/component_base.md
27///
28/// ## Static configuration example:
29///
30/// @snippet components/common_component_list_test.cpp Sample dynamic configs client component config
32public:
33 /// @ingroup userver_component_names
34 /// @brief The default name of @ref components::DynamicConfigClient
35 static constexpr std::string_view kName = "dynamic-config-client";
36
37 DynamicConfigClient(const ComponentConfig&, const ComponentContext&);
38 ~DynamicConfigClient() override = default;
39
40 [[nodiscard]] dynamic_config::Client& GetClient() const;
41
42 static yaml_config::Schema GetStaticConfigSchema();
43
44private:
45 std::unique_ptr<dynamic_config::Client> config_client_;
46};
47
48template <>
49inline constexpr bool kHasValidate<DynamicConfigClient> = true;
50
51} // namespace components
52
53USERVER_NAMESPACE_END