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
5
6
#include <chrono>
7
#include <optional>
8
#include <string>
9
#include <unordered_map>
10
#include <vector>
11
12
#include <
userver/dynamic_config/value.hpp
>
13
#include <
userver/formats/json/value.hpp
>
14
15
USERVER_NAMESPACE_BEGIN
16
17
namespace
clients::http
{
18
class
Client
;
19
}
// namespace clients::http
20
21
namespace
dynamic_config {
22
23
struct
ClientConfig
{
24
std::string service_name;
26
bool
get_configs_overrides_for_service
{
true
};
27
std::chrono::milliseconds timeout{0};
28
int
retries{1};
29
std::string config_url;
31
std::vector<std::string>
fallback_config_urls
;
32
bool
append_path_to_url{
true
};
33
std::string stage_name;
34
bool
is_prestable{
false
};
35
std::string circuit;
37
std::vector<std::string>
service_overrides
;
39
std::unordered_map<std::string, formats::json::Value>
additional_request_params
{};
40
};
41
49
class
Client final {
50
public
:
51
Client(
clients::http::Client
& http_client,
const
ClientConfig
&);
52
53
~Client();
54
55
using
Timestamp = std::string;
56
57
struct
Reply
{
58
USERVER_NAMESPACE::dynamic_config::DocsMap docs_map;
59
std::vector<std::string> kill_switches_disabled;
60
std::vector<std::string> removed;
61
Timestamp timestamp;
62
63
bool
IsEmpty()
const
{
return
docs_map.Size() == 0 && removed.empty(); }
64
};
65
66
struct
JsonReply
{
67
formats::json::Value
configs;
68
std::vector<std::string> kill_switches_disabled;
69
Timestamp timestamp;
70
};
71
72
Reply
DownloadFullDocsMap();
73
74
Reply
FetchDocsMap(
const
std::optional<Timestamp>& last_update,
const
std::vector<std::string>& fields_to_load);
75
76
JsonReply
FetchJson(
const
std::optional<Timestamp>& last_update,
const
std::vector<std::string>& fields_to_load);
77
78
private
:
79
formats::json::Value
FetchConfigs(
80
const
std::optional<Timestamp>& last_update,
81
const
std::vector<std::string>& fields_to_load
82
);
83
84
std::string FetchConfigsValues(std::string_view body);
85
86
std::string FetchConfigsValuesFrom(
const
std::string& url, std::string_view body);
87
88
const
ClientConfig
config_;
89
const
std::vector<std::string> urls_;
90
clients::http::Client
& http_client_;
91
};
92
93
}
// namespace dynamic_config
94
95
USERVER_NAMESPACE_END
userver
dynamic_config
client
client.hpp
Generated on
for userver by
Doxygen
1.17.0