userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
client.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/dynamic_config/client/client.hpp
4
/// @brief @copybrief dynamic_config::Client
5
6
#
include
<
chrono
>
7
#
include
<
optional
>
8
#
include
<
string
>
9
#
include
<
vector
>
10
11
#
include
<
userver
/
dynamic_config
/
value
.
hpp
>
12
13
USERVER_NAMESPACE_BEGIN
14
15
namespace
clients::
http
{
16
class
Client;
17
}
// namespace clients::http
18
19
namespace
dynamic_config {
20
21
struct
ClientConfig
{
22
std::string service_name;
23
/// When true, sends `service`. Mutually exclusive with non-empty `service_overrides`.
24
bool
get_configs_overrides_for_service
{
true
};
25
std::chrono::milliseconds timeout{0};
26
int
retries{1};
27
std::string config_url;
28
bool
append_path_to_url{
true
};
29
std::string stage_name;
30
bool
is_prestable{
false
};
31
std::string circuit;
32
/// Ordered service names sent as `service_overrides`. Mutually exclusive with `service`.
33
std
::
vector
<
std
::
string
>
service_overrides
;
34
};
35
36
/// @ingroup userver_clients
37
///
38
/// @brief Client for the
39
/// @ref scripts/docs/en/userver/dynamic_config.md "dynamic configs" service.
40
///
41
/// It is safe to concurrently invoke members of the same client because this
42
/// client is a thin wrapper around @ref clients::http::Client.
43
class
Client
final
{
44
public
:
45
Client(clients::
http
::Client& http_client,
const
ClientConfig
&);
46
47
~Client();
48
49
using
Timestamp = std::string;
50
51
struct
Reply
{
52
USERVER_NAMESPACE::dynamic_config::DocsMap docs_map;
53
std::vector<std::string> kill_switches_disabled;
54
std::vector<std::string> removed;
55
Timestamp timestamp;
56
57
bool
IsEmpty()
const
{
return
docs_map.Size() == 0 && removed.empty(); }
58
};
59
60
struct
JsonReply
{
61
formats::json::Value configs;
62
std::vector<std::string> kill_switches_disabled;
63
Timestamp timestamp;
64
};
65
66
Reply
DownloadFullDocsMap();
67
68
Reply
FetchDocsMap(
const
std::optional<Timestamp>& last_update,
const
std::vector<std::string>& fields_to_load);
69
70
JsonReply
FetchJson(
const
std::optional<Timestamp>& last_update,
const
std::vector<std::string>& fields_to_load);
71
72
private
:
73
formats::json::Value FetchConfigs(
74
const
std::optional<Timestamp>& last_update,
75
const
std::vector<std::string>& fields_to_load
76
);
77
78
std::string FetchConfigsValues(std::string_view body);
79
80
const
ClientConfig
config_;
81
clients::
http
::Client& http_client_;
82
};
83
84
}
// namespace dynamic_config
85
86
USERVER_NAMESPACE_END
userver
dynamic_config
client
client.hpp
Generated on
for userver by
Doxygen
1.17.0