25#include <boost/intrusive/list.hpp>
27#include <seastar/net/api.hh>
28#include <seastar/http/connection_factory.hh>
29#include <seastar/http/reply.hh>
30#include <seastar/core/condition-variable.hh>
31#include <seastar/core/iostream.hh>
32#include <seastar/util/modules.hh>
34namespace bi = boost::intrusive;
38SEASTAR_MODULE_EXPORT_BEGIN
44namespace experimental {
class client; }
61namespace experimental {
71 using hook_t = bi::list_member_hook<bi::link_mode<bi::auto_unlink>>;
72 using reply_ptr = std::unique_ptr<reply>;
83 bool _persistent =
true;
131 void setup_request(
request& rq);
137 void shutdown() noexcept;
158 using connections_list_t = bi::list<connection, bi::member_hook<connection, typename connection::hook_t, &connection::_hook>, bi::constant_time_size<false>>;
159 static constexpr unsigned default_max_connections = 100;
161 std::unique_ptr<connection_factory> _new_connections;
162 unsigned _nr_connections = 0;
163 unsigned _max_connections;
164 unsigned long _total_new_connections = 0;
167 connections_list_t _pool;
176 template <std::invocable<connection&> Fn>
179 template <
typename Fn>
180 requires std::invocable<Fn, connection&>
248 explicit client(std::unique_ptr<connection_factory> f,
unsigned max_connections = default_max_connections,
retry_requests retry = retry_requests::no);
300 return _nr_connections;
319 return _total_new_connections;
327SEASTAR_MODULE_EXPORT_END
Definition: abort_source.hh:59
Type-safe boolean.
Definition: bool_class.hh:58
Conditional variable.
Definition: condition-variable.hh:73
Definition: shared_ptr.hh:493
A representation of a possibly not-yet-computed value.
Definition: future.hh:1197
Class client wraps communications using HTTP protocol.
Definition: client.hh:151
client(std::unique_ptr< connection_factory > f, unsigned max_connections=default_max_connections, retry_requests retry=retry_requests::no)
Construct a client with connection factory.
unsigned idle_connections_nr() const noexcept
Returns the number of idle connections.
Definition: client.hh:307
unsigned long total_new_connections_nr() const noexcept
Returns the total number of connection factory invocations made so far.
Definition: client.hh:318
unsigned connections_nr() const noexcept
Returns the total number of connections.
Definition: client.hh:299
future make_request(request &&req, reply_handler &&handle, std::optional< reply::status_type > &&expected=std::nullopt, abort_source *as=nullptr)
Send the request and handle the response.
future close()
Closes the client.
future set_maximum_connections(unsigned nr)
Updates the maximum number of connections a client may have.
client(socket_address addr, shared_ptr< tls::certificate_credentials > creds, sstring host={})
Construct a secure client.
future make_request(request &req, reply_handler &handle, std::optional< reply::status_type > expected=std::nullopt, abort_source *as=nullptr)
Send the request and handle the response (abortable), same as make_request()
client(socket_address addr)
Construct a simple client.
Class connection represents an HTTP connection over a given transport.
Definition: client.hh:69
input_stream< char > in(reply &rep)
Get a reference on the connection input stream.
future close()
Closes the connection.
connection(connected_socket &&fd, internal::client_ref cr)
Create an http connection.
future< reply > make_request(request rq)
Send the request and wait for response.
Definition: shared_ptr.hh:507
Definition: socket_defs.hh:47
Seastar API namespace.
Definition: abort_on_ebadf.hh:26
Definition: noncopyable_function.hh:37
Definition: request.hh:52