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 server::http {
17class HeadersPropagator;
18} // namespace server::http
19
20namespace clients::http {
21
23 bool update_header{true};
24};
25
26enum class CancellationPolicy {
27 kIgnore,
28 kCancel,
29};
30
31CancellationPolicy Parse(yaml_config::YamlConfig value,
32 formats::parse::To<CancellationPolicy>);
33
34// Static config
35struct ClientSettings final {
36 std::string thread_name_prefix{};
37 size_t io_threads{8};
38 bool defer_events{false};
39 DeadlinePropagationConfig deadline_propagation{};
40 const tracing::TracingManagerBase* tracing_manager{nullptr};
41 const server::http::HeadersPropagator* headers_propagator{nullptr};
42 CancellationPolicy cancellation_policy{CancellationPolicy::kCancel};
43};
44
45ClientSettings Parse(const yaml_config::YamlConfig& value,
46 formats::parse::To<ClientSettings>);
47
48} // namespace clients::http
49
50namespace clients::http::impl {
51
52struct ThrottleConfig final {
53 static constexpr size_t kNoLimit = -1;
54
55 std::size_t http_connect_limit{kNoLimit};
56 std::chrono::microseconds http_connect_rate{0};
57 std::size_t https_connect_limit{kNoLimit};
58 std::chrono::microseconds https_connect_rate{0};
59 std::size_t per_host_connect_limit{kNoLimit};
60 std::chrono::microseconds per_host_connect_rate{0};
61};
62
63ThrottleConfig Parse(const formats::json::Value& value,
64 formats::parse::To<ThrottleConfig>);
65
66// Dynamic config
67struct Config final {
68 static constexpr std::size_t kDefaultConnectionPoolSize = 10000;
69
70 std::size_t connection_pool_size{kDefaultConnectionPoolSize};
71 std::string proxy;
72 ThrottleConfig throttle;
73};
74
75Config ParseConfig(const dynamic_config::DocsMap& docs_map);
76
77} // namespace clients::http::impl
78
79USERVER_NAMESPACE_END