userver: userver/clients/http/config.hpp Source File
Loading...
Searching...
No Matches
config.hpp
1#pragma once
2
3#include <chrono>
4#include <optional>
5#include <string>
6
7#include <userver/clients/http/cancellation_policy.hpp>
8#include <userver/dynamic_config/fwd.hpp>
9#include <userver/formats/json_fwd.hpp>
10#include <userver/yaml_config/fwd.hpp>
11
12namespace dynamic_config::http_client_connect_throttle {
13struct VariableTypeRaw;
14using VariableType = VariableTypeRaw;
15} // namespace dynamic_config::http_client_connect_throttle
16
17USERVER_NAMESPACE_BEGIN
18
19namespace tracing {
21} // namespace tracing
22
23namespace clients::http {
24
26 bool update_header{true};
27};
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 ::dynamic_config::http_client_connect_throttle::VariableType&);
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 ThrottleConfig throttle;
63};
64
65} // namespace clients::http::impl
66
67USERVER_NAMESPACE_END