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