Kagome
Polkadot Runtime Engine in C++17
|
#include <jrpc_server_impl.hpp>
Public Types | |
enum | Error { Error::JSON_FORMAT_FAILED = 1 } |
Public Types inherited from kagome::api::JRpcServer | |
using | Method = jsonrpc::MethodWrapper::Method |
using | ResponseHandler = std::function< void(std::string_view)> |
using | FormatterHandler = std::function< void(outcome::result< std::string_view >)> |
Public Member Functions | |
JRpcServerImpl () | |
~JRpcServerImpl () override=default | |
void | registerHandler (const std::string &name, Method method) override |
registers rpc request handler lambda More... | |
std::vector< std::string > | getHandlerNames () override |
void | processData (std::string_view request, const ResponseHandler &cb) override |
handles decoded network message More... | |
void | processJsonData (std::string method_name, const jsonrpc::Request::Parameters &from, const FormatterHandler &cb) override |
creates a valid jsonrpc response and passes it to More... | |
Public Member Functions inherited from kagome::api::JRpcServer | |
virtual | ~JRpcServer ()=default |
Private Attributes | |
jsonrpc::Server | jsonrpc_handler_ {} |
json rpc server instance More... | |
jsonrpc::JsonFormatHandler | format_handler_ {} |
format handler instance More... | |
metrics::RegistryPtr | metrics_registry_ = metrics::createRegistry() |
metrics::Counter * | metric_rpc_requests_count_ |
Definition at line 16 of file jrpc_server_impl.hpp.
|
strong |
Enumerator | |
---|---|
JSON_FORMAT_FAILED |
Definition at line 18 of file jrpc_server_impl.hpp.
kagome::api::JRpcServerImpl::JRpcServerImpl | ( | ) |
Definition at line 26 of file jrpc_server_impl.cpp.
|
overridedefault |
|
overridevirtual |
Implements kagome::api::JRpcServer.
Definition at line 43 of file jrpc_server_impl.cpp.
|
overridevirtual |
handles decoded network message
request | json request string |
cb | callback |
Implements kagome::api::JRpcServer.
Definition at line 81 of file jrpc_server_impl.cpp.
|
overridevirtual |
creates a valid jsonrpc response and passes it to
from | is a data source |
cb | callback |
Notification must omit "id" field. But jsonrpc-lean writes "id" field if id is null/int/string. So we pass bool. https://github.com/xDimon/jsonrpc-lean/blob/6c093da8670d7bf56555f166f8b8151f33a5d741/include/jsonrpc-lean/jsonwriter.h#L169
Implements kagome::api::JRpcServer.
Definition at line 48 of file jrpc_server_impl.cpp.
|
overridevirtual |
registers rpc request handler lambda
name | rpc method name |
method | handler functor |
Implements kagome::api::JRpcServer.
Definition at line 38 of file jrpc_server_impl.cpp.
|
private |
format handler instance
Definition at line 59 of file jrpc_server_impl.hpp.
|
private |
json rpc server instance
Definition at line 57 of file jrpc_server_impl.hpp.
|
private |
Definition at line 63 of file jrpc_server_impl.hpp.
|
private |
Definition at line 62 of file jrpc_server_impl.hpp.