userver: userver/clients/http/config.hpp Source File
Loading...
Searching...
No Matches
config.hpp
1#pragma once
2
3#include <chrono>
4#include <string>
5
6#include <userver/dynamic_config/fwd.hpp>
7#include <userver/formats/json_fwd.hpp>
8#include <userver/yaml_config/fwd.hpp>
9
10USERVER_NAMESPACE_BEGIN
11
12namespace tracing {
14} // namespace tracing
15
16namespace clients::http {
17
19 bool update_header{true};
20};
21
22enum class CancellationPolicy {
23 kIgnore,
24 kCancel,
25};
26
27CancellationPolicy Parse(yaml_config::YamlConfig value, formats::parse::To<CancellationPolicy>);
28
29// Static config
30struct ClientSettings final {
31 std::string thread_name_prefix{};
32 size_t io_threads{8};
33 DeadlinePropagationConfig deadline_propagation{};
34 const tracing::TracingManagerBase* tracing_manager{nullptr};
35 CancellationPolicy cancellation_policy{CancellationPolicy::kCancel};
36};
37
38ClientSettings Parse(const yaml_config::YamlConfig& value, formats::parse::To<ClientSettings>);
39
40} // namespace clients::http
41
42namespace clients::http::impl {
43
44struct ThrottleConfig final {
45 static constexpr size_t kNoLimit = -1;
46
47 std::size_t http_connect_limit{kNoLimit};
48 std::chrono::microseconds http_connect_rate{0};
49 std::size_t https_connect_limit{kNoLimit};
50 std::chrono::microseconds https_connect_rate{0};
51 std::size_t per_host_connect_limit{kNoLimit};
52 std::chrono::microseconds per_host_connect_rate{0};
53};
54
55ThrottleConfig Parse(const formats::json::Value& value, formats::parse::To<ThrottleConfig>);
56
57// Dynamic config
58struct Config final {
59 static constexpr std::size_t kDefaultConnectionPoolSize = 10000;
60
61 std::size_t connection_pool_size{kDefaultConnectionPoolSize};
62 std::string proxy;
63 ThrottleConfig throttle;
64};
65
66Config ParseConfig(const dynamic_config::DocsMap& docs_map);
67
68} // namespace clients::http::impl
69
70USERVER_NAMESPACE_END