Kagome
Polkadot Runtime Engine in C++17
jrpc_server_impl.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_API_JRPC_SERVER_IMPL_HPP
7 #define KAGOME_API_JRPC_SERVER_IMPL_HPP
8 
9 #include <jsonrpc-lean/server.h>
10 
11 #include "api/jrpc/jrpc_server.hpp"
12 #include "metrics/metrics.hpp"
13 
14 namespace kagome::api {
15 
16  class JRpcServerImpl : public JRpcServer {
17  public:
18  enum class Error {
20  };
21 
23 
24  ~JRpcServerImpl() override = default;
25 
31  void registerHandler(const std::string &name, Method method) override;
32 
36  std::vector<std::string> getHandlerNames() override;
37 
43  void processData(std::string_view request,
44  const ResponseHandler &cb) override;
45 
51  void processJsonData(std::string method_name,
52  const jsonrpc::Request::Parameters &from,
53  const FormatterHandler &cb) override;
54 
55  private:
57  jsonrpc::Server jsonrpc_handler_{};
59  jsonrpc::JsonFormatHandler format_handler_{};
60 
61  // Metrics
64  };
65 
66 } // namespace kagome::api
67 
69 
70 #endif // KAGOME_API_JRPC_SERVER_IMPL_HPP
jsonrpc::Server jsonrpc_handler_
json rpc server instance
OUTCOME_HPP_DECLARE_ERROR(kagome::api, JRpcServerImpl::Error)
~JRpcServerImpl() override=default
std::function< void(outcome::result< std::string_view >)> FormatterHandler
Definition: jrpc_server.hpp:46
std::unique_ptr< Registry > RegistryPtr
Definition: metrics.hpp:15
RegistryPtr createRegistry()
void processJsonData(std::string method_name, const jsonrpc::Request::Parameters &from, const FormatterHandler &cb) override
creates a valid jsonrpc response and passes it to
void registerHandler(const std::string &name, Method method) override
registers rpc request handler lambda
std::function< void(std::string_view)> ResponseHandler
Definition: jrpc_server.hpp:44
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
Definition: jrpc_server.hpp:25
metrics::RegistryPtr metrics_registry_
A counter metric to represent a monotonically increasing value.
Definition: metrics.hpp:27