25#include <boost/intrusive/list.hpp>
27#include <seastar/net/api.hh>
28#include <seastar/http/reply.hh>
29#include <seastar/core/condition-variable.hh>
30#include <seastar/core/iostream.hh>
31#include <seastar/util/modules.hh>
33namespace bi = boost::intrusive;
37SEASTAR_MODULE_EXPORT_BEGIN
43namespace experimental {
class client; }
60namespace experimental {
70 using hook_t = bi::list_member_hook<bi::link_mode<bi::auto_unlink>>;
71 using reply_ptr = std::unique_ptr<reply>;
82 bool _persistent =
true;
130 void setup_request(
request& rq);
136 void shutdown() noexcept;
177 using connections_list_t = bi::list<connection, bi::member_hook<connection, typename connection::hook_t, &connection::_hook>, bi::constant_time_size<false>>;
178 static constexpr unsigned default_max_connections = 100;
180 std::unique_ptr<connection_factory> _new_connections;
181 unsigned _nr_connections = 0;
182 unsigned _max_connections;
183 unsigned long _total_new_connections = 0;
186 connections_list_t _pool;
195 template <std::invocable<connection&> Fn>
198 template <
typename Fn>
199 requires std::invocable<Fn, connection&>
268 explicit client(std::unique_ptr<connection_factory> f,
unsigned max_connections = default_max_connections,
retry_requests retry = retry_requests::no);
340 return _nr_connections;
359 return _total_new_connections;
367SEASTAR_MODULE_EXPORT_END
Definition: abort_source.hh:58
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:1240
Class client wraps communications using HTTP protocol.
Definition: client.hh:170
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.
future make_request(request &&req, reply_handler &&handle, abort_source &as, std::optional< reply::status_type > &&expected=std::nullopt)
Send the request and handle the response (abortable)
future make_request(request &&req, reply_handler &&handle, std::optional< reply::status_type > &&expected=std::nullopt)
Send the request and handle the response.
unsigned idle_connections_nr() const noexcept
Returns the number of idle connections.
Definition: client.hh:347
future make_request(request &req, reply_handler &handle, std::optional< reply::status_type > expected=std::nullopt)
Send the request and handle the response, same as make_request()
unsigned long total_new_connections_nr() const noexcept
Returns the total number of connection factory invocations made so far.
Definition: client.hh:358
unsigned connections_nr() const noexcept
Returns the total number of connections.
Definition: client.hh:339
future make_request(request &req, reply_handler &handle, abort_source &as, std::optional< reply::status_type > expected=std::nullopt)
Send the request and handle the response (abortable), same as make_request()
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.
client(socket_address addr)
Construct a simple client.
Factory that provides transport for client.
Definition: client.hh:147
virtual future< connected_socket > make(abort_source *)=0
Make a connected_socket.
Class connection represents an HTTP connection over a given transport.
Definition: client.hh:68
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