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/loggable_component_base.hpp>
7#include <userver/dynamic_config/client/client.hpp>
8
9USERVER_NAMESPACE_BEGIN
10
11namespace components {
12
13// clang-format off
14
15/// @ingroup userver_components
16///
17/// @brief Component that starts a clients::dynamic_config::Client client.
18///
19/// Returned references to clients::dynamic_config::Client live for a lifetime
20/// of the component and are safe for concurrent use.
21///
22/// The component must be configured in service config.
23///
24/// ## Static options:
25/// Name | Description | Default value
26/// ---- | ----------- | -------------
27/// get-configs-overrides-for-service | send service-name field | true
28/// service-name | name of the service to send if the get-configs-overrides-for-service is true | -
29/// http-timeout | HTTP request timeout to the remote in utils::StringToDuration() suitable format | -
30/// http-retries | HTTP retries before reporting the request failure | -
31/// config-url | HTTP URL to request configs via POST request | -
32/// append-path-to-url | add default path '/configs/values' to 'config-url' | true
33/// configs-stage: stage name provided statically, can be overridden from file | -
34/// configs-stage-filepath: file to read stage name from, overrides static "configs-stage" if both are provided, expected format: json file with "env_name" property | -
35/// fallback-to-no-proxy | make additional attempts to retrieve configs by bypassing proxy that is set in USERVER_HTTP_PROXY runtime variable | true
36///
37/// ## Static configuration example:
38///
39/// @snippet components/common_component_list_test.cpp Sample dynamic configs client component config
40
41// clang-format on
43 public:
44 /// @ingroup userver_component_names
45 /// @brief The default name of components::DynamicConfigClient
46 static constexpr std::string_view kName = "dynamic-config-client";
47
48 DynamicConfigClient(const ComponentConfig&, const ComponentContext&);
49 ~DynamicConfigClient() override = default;
50
51 [[nodiscard]] dynamic_config::Client& GetClient() const;
52
53 static yaml_config::Schema GetStaticConfigSchema();
54
55 private:
56 std::unique_ptr<dynamic_config::Client> config_client_;
57};
58
59template <>
60inline constexpr bool kHasValidate<DynamicConfigClient> = true;
61
62} // namespace components
63
64USERVER_NAMESPACE_END