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