|
| client ()=default |
|
| client (client &&) noexcept=default |
|
auto | operator= (client &&) noexcept -> client &=default |
|
| client (const client &)=delete |
|
auto | operator= (const client &) -> client &=delete |
|
virtual | ~client ()=default |
|
auto | call (Request request_payload, std::chrono::milliseconds timeout=std::chrono::milliseconds::zero()) -> std::optional< Response > |
| Issues the given request with an optional timeout, then waits for and returns the response.
|
|
auto | call (Request request_payload, response_callback_type response_callback) -> bool |
| Issues an asynchronous request and registers the given callback to handle the response.
|
|
template<typename Request, typename Response>
class cbdc::rpc::client< Request, Response >
Generic RPC client.
Handles serialization of requests and responses combined with a message header. Subclass to define actual remote communication logic.
- Template Parameters
-
Request | type for requests. |
Response | type for responses. |
Definition at line 26 of file util/rpc/client.hpp.
template<typename Request , typename Response >
Issues an asynchronous request and registers the given callback to handle the response.
Serializes the request data, then transmits it with call_raw(). Thread safe.
- Parameters
-
request_payload | payload for the RPC. |
response_callback | function for the request handler to call when the response is available. |
- Returns
- true if the request was sent successfully.
Definition at line 73 of file util/rpc/client.hpp.
template<typename Request , typename Response >
auto cbdc::rpc::client< Request, Response >::call |
( |
Request | request_payload, |
|
|
std::chrono::milliseconds | timeout = std::chrono::milliseconds::zero() ) -> std::optional<Response> |
|
inlinenodiscard |
Issues the given request with an optional timeout, then waits for and returns the response.
Serializes the request data, calls call_raw() to transmit the data and get a response, and returns the deserialized response. Thread safe.
- Parameters
-
request_payload | payload for the RPC. |
timeout | optional timeout in milliseconds. Zero indicates the call should not timeout. |
- Returns
- response from the RPC, or std::nullopt if the call timed out or produced an error.
Definition at line 52 of file util/rpc/client.hpp.