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