2#include <Hermes/Socket/ClientSocket.hpp>
13 template<MethodConcept Method, ResponseBodyConcept ResponseBody>
24 std::chrono::steady_clock::time_point
lastUsed;
42 std::unordered_map<Hermes::IpEndpoint, std::vector<std::shared_ptr<Socket>>>
connectionPool;
44 std::atomic_bool _isRunning{
true };
48 std::jthread _janitorThread;
60 template<
class F,
class Body>
62 requires (F f,
const ResponseHead& head){ { std::invoke(f, head) } -> std::same_as<std::expected<Body, RequestError>>; };
66 template<MethodConcept Method, BodyConcept Body>
67 requires std::default_initializable<Body>
71 template<MethodConcept Method, BodyConcept Body,
class F>
76 template<MethodConcept Method, RequestBodyConcept RequestBody, ResponseBodyConcept ResponseBody>
77 requires std::default_initializable<ResponseBody>
81 template<MethodConcept Method, RequestBodyConcept RequestBody, ResponseBodyConcept ResponseBody,
class F>
92 template<ResponseBodyConcept ResponseBody>
95 template<ResponseBodyConcept ResponseBody,
class F>
106 template<MethodConcept Method, ResponseBodyConcept ResponseBody,
class F>
108 static expected<std::pair<SocketPtr, Response<Method, ResponseBody>>,
RequestError> P_ParseHttp11(
SocketPtr infoPtr, F&& bodyFactory);
119#include <Thoth/Http/Client.tpp>
Class that transforms requests with a given method into their responses, monad friendly.
Definition Client.hpp:58
Definition Request.hpp:36
Definition Response.hpp:15
VersionEnum
Definition Request.hpp:11
static auto H_SendAndRecvAsInto(F &&bodyFactory)
static expected< Response< Method, ResponseBody >, RequestError > SendAndRecvAs(Request< Method, RequestBody > request)
Sends synced (thread blocking) requests.
std::shared_ptr< Socket > SocketPtr
Definition Client.hpp:99
static constexpr auto H_Send()
@hof{Send}
static expected< Response< Method, Body >, RequestError > SendAndRecvInto(Request< Method, Body > request, F &&bodyFactory)
Sends synced (thread blocking) requests.
static expected< Response< Method, Body >, RequestError > Send(Request< Method, Body > request)
Sends synced (thread blocking) requests.
static auto H_SendAndRecvInto(F &&bodyFactory)
static constexpr auto H_SendAndRecvAs()
@hof{SendAndGetAs}
static expected< Response< Method, ResponseBody >, RequestError > SendAndRecvAsInto(Request< Method, RequestBody > request, F &&bodyFactory)
Sends synced (thread blocking) requests.
The ClientJanitor stores all open Sockets in a pool to optimize consecutive calls....
Definition Client.hpp:33
std::unordered_map< Hermes::IpEndpoint, std::vector< std::shared_ptr< Socket > > > connectionPool
Group multiple sockets connected to the same endpoint. Before using it lock the poolMutex to not brea...
Definition Client.hpp:42
std::mutex poolMutex
Definition Client.hpp:38
static ClientJanitor & Instance()
Definition RequestError.hpp:71
Definition Request.hpp:41
Definition Response.hpp:26
structure that stores info about an open Socket, like the version, the type of socket and the last us...
Definition Client.hpp:18
Hermes::RawTlsClient socket
Definition Client.hpp:21
std::chrono::steady_clock::time_point lastUsed
Definition Client.hpp:24
VersionEnum version
Definition Client.hpp:22