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;
47struct TestsuiteConfig;
50struct InstanceStatistics;
51class DestinationStatistics;
65 Client(ClientSettings settings, engine::TaskProcessor& fs_task_processor,
66 impl::PluginPipeline&& plugin_pipeline);
83 void SetMultiplexingEnabled(
bool enabled);
86 void SetMaxHostConnections(size_t max_host_connections);
89 PoolStatistics GetPoolStatistics()
const;
93 void SetDestinationMetricsAutoMaxSize(size_t max_size);
96 const http::DestinationStatistics& GetDestinationStatistics()
const;
99 void SetTestsuiteConfig(
const TestsuiteConfig& config);
102 void SetAllowedUrlsExtra(std::vector<std::string>&& urls);
105 void SetConfig(
const impl::Config&);
131 InstanceStatistics GetMultiStatistics(size_t n)
const;
133 size_t FindMultiIndex(
const curl::multi*)
const;
137 friend class impl::EasyWrapper;
138 void IncPending()
noexcept { ++pending_tasks_; }
139 void DecPending()
noexcept { --pending_tasks_; }
140 void PushIdleEasy(std::shared_ptr<curl::easy>&& easy)
noexcept;
142 std::shared_ptr<curl::easy> TryDequeueIdle()
noexcept;
144 std::atomic<std::size_t> pending_tasks_{0};
147 CancellationPolicy cancellation_policy_;
149 std::shared_ptr<DestinationStatistics> destination_statistics_;
150 std::unique_ptr<engine::ev::ThreadPool> thread_pool_;
151 std::vector<Statistics> statistics_;
152 std::vector<std::unique_ptr<curl::multi>> multis_;
154 static constexpr size_t kIdleQueueSize = 616;
155 static constexpr size_t kIdleQueueAlignment = 8;
156 using IdleQueueTraits = moodycamel::ConcurrentQueueDefaultTraits;
157 using IdleQueueValue = std::shared_ptr<curl::easy>;
159 moodycamel::ConcurrentQueue<IdleQueueValue, IdleQueueTraits>;
160 utils::FastPimpl<IdleQueue, kIdleQueueSize, kIdleQueueAlignment> idle_queue_;
162 engine::TaskProcessor& fs_task_processor_;
163 std::optional<std::string> user_agent_;
164 rcu::Variable<std::string> proxy_;
167 utils::PeriodicTask easy_reinit_task_;
170 std::shared_ptr<
const TestsuiteConfig> testsuite_config_;
171 rcu::Variable<std::vector<std::string>> allowed_urls_extra_;
173 std::shared_ptr<curl::ConnectRateLimiter> connect_rate_limiter_;
175 clients::dns::Resolver* resolver_{
nullptr};
177 impl::PluginPipeline plugin_pipeline_;