14 case E::JSON_FORMAT_FAILED:
15 return "Json format failed";
17 return "Unknown error";
21 constexpr
auto rpcRequestsCountMetricName =
"kagome_rpc_requests_count";
32 "Block height info of the chain");
40 dispatcher.AddMethod(name, std::move(method));
45 return dispatcher.GetMethodNames();
49 const jsonrpc::Request::Parameters &from,
55 using Response = jsonrpc::Request;
56 using Fault = jsonrpc::Fault;
66 constexpr
bool id =
false;
67 Response response(std::move(method_name), from,
id);
68 response.Write(writer);
70 auto &&formatted_response = writer.
GetData();
71 cb(std::string_view(formatted_response->GetData(),
72 formatted_response->GetSize()));
74 }
catch (
const Fault &ex) {
std::string_view response() const
jsonrpc::Server jsonrpc_handler_
json rpc server instance
std::function< void(outcome::result< std::string_view >)> FormatterHandler
OUTCOME_CPP_DEFINE_CATEGORY(kagome::api, JRpcServerImpl::Error, e)
void processJsonData(std::string method_name, const jsonrpc::Request::Parameters &from, const FormatterHandler &cb) override
creates a valid jsonrpc response and passes it to
virtual void inc()=0
Increment the counter by 1.
void registerHandler(const std::string &name, Method method) override
registers rpc request handler lambda
std::function< void(std::string_view)> ResponseHandler
jsonrpc::JsonFormatHandler format_handler_
format handler instance
metrics::Counter * metric_rpc_requests_count_
std::vector< std::string > getHandlerNames() override
void processData(std::string_view request, const ResponseHandler &cb) override
handles decoded network message
jsonrpc::MethodWrapper::Method Method
metrics::RegistryPtr metrics_registry_
std::shared_ptr< jsonrpc::FormattedData > GetData() override