|
OpenCBDC Transaction Processor
|
Asynchronous HTTP JSON-RPC client implemented using libcurl. More...
#include <json_rpc_http_client.hpp>
Public Types | |
| using | callback_type = std::function<void(std::optional<Json::Value>)> |
| Type alias for the response callback function. | |
Public Member Functions | |
| json_rpc_http_client (std::vector< std::string > endpoints, long timeout, std::shared_ptr< logging::log > log) | |
| Construct a new client. | |
| ~json_rpc_http_client () | |
| Cancels any existing requests and stops the client. | |
| json_rpc_http_client (const json_rpc_http_client &)=delete | |
| auto | operator= (const json_rpc_http_client &) -> json_rpc_http_client &=delete |
| json_rpc_http_client (json_rpc_http_client &&)=delete | |
| auto | operator= (json_rpc_http_client &&) -> json_rpc_http_client &=delete |
| void | call (const std::string &method, Json::Value params, callback_type result_fn) |
| Calls the requested JSON-RPC method with the given parameters and returns the response asynchronously via a callback function. | |
| auto | pump () -> bool |
| Process events raised by the underlying libcurl implementation. | |
Protected Attributes | |
| std::shared_ptr< cbdc::logging::log > | m_log |
Asynchronous HTTP JSON-RPC client implemented using libcurl.
Supports randomized load balancing across multiple RPC endpoints.
Definition at line 36 of file json_rpc_http_client.hpp.
| using cbdc::rpc::json_rpc_http_client::callback_type = std::function<void(std::optional<Json::Value>)> |
Type alias for the response callback function.
Definition at line 56 of file json_rpc_http_client.hpp.
| cbdc::rpc::json_rpc_http_client::json_rpc_http_client | ( | std::vector< std::string > | endpoints, |
| long | timeout, | ||
| std::shared_ptr< logging::log > | log ) |
Construct a new client.
| endpoints | list of RPC endpoints to load balance between. |
| timeout | response timeout in milliseconds. 0 for no timeout. |
| log | log instance. |
Definition at line 27 of file json_rpc_http_client.cpp.
| cbdc::rpc::json_rpc_http_client::~json_rpc_http_client | ( | ) |
Cancels any existing requests and stops the client.
Definition at line 60 of file json_rpc_http_client.cpp.
References m_log.
|
delete |
|
delete |
| void cbdc::rpc::json_rpc_http_client::call | ( | const std::string & | method, |
| Json::Value | params, | ||
| callback_type | result_fn ) |
Calls the requested JSON-RPC method with the given parameters and returns the response asynchronously via a callback function.
| method | method to call. |
| params | call parameters. |
| result_fn | function to call with response. |
Definition at line 79 of file json_rpc_http_client.cpp.
References m_log.
|
delete |
|
delete |
|
nodiscard |
Process events raised by the underlying libcurl implementation.
Definition at line 130 of file json_rpc_http_client.cpp.
|
protected |
Definition at line 113 of file json_rpc_http_client.hpp.
Referenced by call(), and ~json_rpc_http_client().