6#ifdef USERVER_TVM2_HTTP_CLIENT
7#error Use clients::Http from clients/http.hpp instead
12#include <userver/moodycamel/concurrentqueue_fwd.h>
14#include <userver/clients/dns/resolver_fwd.hpp>
15#include <userver/clients/http/config.hpp>
16#include <userver/clients/http/plugin.hpp>
17#include <userver/clients/http/request.hpp>
18#include <userver/engine/task/task_processor_fwd.hpp>
19#include <userver/rcu/rcu.hpp>
20#include <userver/utils/fast_pimpl.hpp>
21#include <userver/utils/not_null.hpp>
22#include <userver/utils/periodic_task.hpp>
23#include <userver/utils/swappingsmart.hpp>
24#include <userver/yaml_config/fwd.hpp>
26USERVER_NAMESPACE_BEGIN
35class ConnectRateLimiter;
42namespace clients::
http {
47struct TestsuiteConfig;
50struct InstanceStatistics;
51class DestinationStatistics;
65 Client(ClientSettings settings, engine::TaskProcessor& fs_task_processor, impl::PluginPipeline&& plugin_pipeline);
82 void SetMultiplexingEnabled(
bool enabled);
85 void SetMaxHostConnections(size_t max_host_connections);
88 PoolStatistics GetPoolStatistics()
const;
92 void SetDestinationMetricsAutoMaxSize(size_t max_size);
95 const http::DestinationStatistics& GetDestinationStatistics()
const;
98 void SetTestsuiteConfig(
const TestsuiteConfig& config);
101 void SetAllowedUrlsExtra(std::vector<std::string>&& urls);
104 void SetConfig(
const impl::Config&);
130 InstanceStatistics GetMultiStatistics(size_t n)
const;
132 size_t FindMultiIndex(
const curl::multi*)
const;
136 friend class impl::EasyWrapper;
137 void IncPending()
noexcept { ++pending_tasks_; }
138 void DecPending()
noexcept { --pending_tasks_; }
139 void PushIdleEasy(std::shared_ptr<curl::easy>&& easy)
noexcept;
141 std::shared_ptr<curl::easy> TryDequeueIdle()
noexcept;
143 std::atomic<std::size_t> pending_tasks_{0};
146 CancellationPolicy cancellation_policy_;
148 std::shared_ptr<DestinationStatistics> destination_statistics_;
149 std::unique_ptr<engine::ev::ThreadPool> thread_pool_;
150 std::vector<Statistics> statistics_;
151 std::vector<std::unique_ptr<curl::multi>> multis_;
153 static constexpr size_t kIdleQueueSize = 616;
154 static constexpr size_t kIdleQueueAlignment = 8;
155 using IdleQueueTraits = moodycamel::ConcurrentQueueDefaultTraits;
156 using IdleQueueValue = std::shared_ptr<curl::easy>;
157 using IdleQueue = moodycamel::ConcurrentQueue<IdleQueueValue, IdleQueueTraits>;
158 utils::FastPimpl<IdleQueue, kIdleQueueSize, kIdleQueueAlignment> idle_queue_;
160 engine::TaskProcessor& fs_task_processor_;
161 std::optional<std::string> user_agent_;
162 rcu::Variable<std::string> proxy_;
165 utils::PeriodicTask easy_reinit_task_;
168 std::shared_ptr<
const TestsuiteConfig> testsuite_config_;
169 rcu::Variable<std::vector<std::string>> allowed_urls_extra_;
171 std::shared_ptr<curl::ConnectRateLimiter> connect_rate_limiter_;
173 clients::dns::Resolver* resolver_{
nullptr};
175 impl::PluginPipeline plugin_pipeline_;