Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
rpc::RPCEngine< LoadBalancerType, CountersType > Class Template Reference

The RPC engine that ties all RPC-related functionality together. More...

#include <RPCEngine.hpp>

Public Member Functions

 RPCEngine (util::config::ClioConfigDefinition const &config, std::shared_ptr< BackendInterface > const &backend, std::shared_ptr< LoadBalancerType > const &balancer, web::dosguard::DOSGuardInterface const &dosGuard, WorkQueue &workQueue, CountersType &counters, std::shared_ptr< HandlerProvider const > const &handlerProvider)
 Construct a new RPCEngine object.
 
Result buildResponse (web::Context const &ctx)
 Main request processor routine.
 
template<typename FnType >
bool post (FnType &&func, std::string const &ip)
 Used to schedule request processing onto the work queue.
 
void notifyComplete (std::string const &method, std::chrono::microseconds const &duration)
 Notify the system that specified method was executed.
 
void notifyFailed (std::string const &method)
 Notify the system that specified method failed to execute due to a recoverable user error.
 
void notifyErrored (std::string const &method)
 Notify the system that specified method failed due to some unrecoverable error.
 
void notifyTooBusy ()
 Notify the system that the RPC system is too busy to handle an incoming request.
 
void notifyNotReady ()
 Notify the system that the RPC system was not ready to handle an incoming request.
 
void notifyBadSyntax ()
 Notify the system that the incoming request did not specify the RPC method/command.
 
void notifyUnknownCommand ()
 Notify the system that the incoming request specified an unknown/unsupported method/command.
 
void notifyInternalError ()
 Notify the system that the incoming request lead to an internal error (unrecoverable).
 

Static Public Member Functions

static std::shared_ptr< RPCEnginemakeRPCEngine (util::config::ClioConfigDefinition const &config, std::shared_ptr< BackendInterface > const &backend, std::shared_ptr< LoadBalancerType > const &balancer, web::dosguard::DOSGuardInterface const &dosGuard, WorkQueue &workQueue, CountersType &counters, std::shared_ptr< HandlerProvider const > const &handlerProvider)
 Factory function to create a new instance of the RPC engine.
 

Detailed Description

template<typename LoadBalancerType, typename CountersType>
class rpc::RPCEngine< LoadBalancerType, CountersType >

The RPC engine that ties all RPC-related functionality together.

Constructor & Destructor Documentation

◆ RPCEngine()

template<typename LoadBalancerType , typename CountersType >
rpc::RPCEngine< LoadBalancerType, CountersType >::RPCEngine ( util::config::ClioConfigDefinition const & config,
std::shared_ptr< BackendInterface > const & backend,
std::shared_ptr< LoadBalancerType > const & balancer,
web::dosguard::DOSGuardInterface const & dosGuard,
WorkQueue & workQueue,
CountersType & counters,
std::shared_ptr< HandlerProvider const > const & handlerProvider )
inline

Construct a new RPCEngine object.

Parameters
configThe config to use
backendThe backend to use
balancerThe load balancer to use
dosGuardThe DOS guard to use
workQueueThe work queue to use
countersThe counters to use
handlerProviderThe handler provider to use

Member Function Documentation

◆ buildResponse()

template<typename LoadBalancerType , typename CountersType >
Result rpc::RPCEngine< LoadBalancerType, CountersType >::buildResponse ( web::Context const & ctx)
inline

Main request processor routine.

Parameters
ctxThe Context of the request
Returns
A result which can be an error status or a valid JSON response

◆ makeRPCEngine()

template<typename LoadBalancerType , typename CountersType >
static std::shared_ptr< RPCEngine > rpc::RPCEngine< LoadBalancerType, CountersType >::makeRPCEngine ( util::config::ClioConfigDefinition const & config,
std::shared_ptr< BackendInterface > const & backend,
std::shared_ptr< LoadBalancerType > const & balancer,
web::dosguard::DOSGuardInterface const & dosGuard,
WorkQueue & workQueue,
CountersType & counters,
std::shared_ptr< HandlerProvider const > const & handlerProvider )
inlinestatic

Factory function to create a new instance of the RPC engine.

Parameters
configThe config to use
backendThe backend to use
balancerThe load balancer to use
dosGuardThe DOS guard to use
workQueueThe work queue to use
countersThe counters to use
handlerProviderThe handler provider to use
Returns
A new instance of the RPC engine

◆ notifyComplete()

template<typename LoadBalancerType , typename CountersType >
void rpc::RPCEngine< LoadBalancerType, CountersType >::notifyComplete ( std::string const & method,
std::chrono::microseconds const & duration )
inline

Notify the system that specified method was executed.

Parameters
method
durationThe time it took to execute the method specified in microseconds

◆ notifyErrored()

template<typename LoadBalancerType , typename CountersType >
void rpc::RPCEngine< LoadBalancerType, CountersType >::notifyErrored ( std::string const & method)
inline

Notify the system that specified method failed due to some unrecoverable error.

Used for erors such as database timeout, internal errors, etc.

Parameters
method

◆ notifyFailed()

template<typename LoadBalancerType , typename CountersType >
void rpc::RPCEngine< LoadBalancerType, CountersType >::notifyFailed ( std::string const & method)
inline

Notify the system that specified method failed to execute due to a recoverable user error.

Used for errors based on user input, not actual failures of the db or clio itself.

Parameters
method

◆ notifyNotReady()

template<typename LoadBalancerType , typename CountersType >
void rpc::RPCEngine< LoadBalancerType, CountersType >::notifyNotReady ( )
inline

Notify the system that the RPC system was not ready to handle an incoming request.

This happens when the backend is not yet have a ledger range

◆ post()

template<typename LoadBalancerType , typename CountersType >
template<typename FnType >
bool rpc::RPCEngine< LoadBalancerType, CountersType >::post ( FnType && func,
std::string const & ip )
inline

Used to schedule request processing onto the work queue.

Template Parameters
FnTypeThe type of function
Parameters
funcThe lambda to execute when this request is handled
ipThe ip address for which this request is being executed
Returns
true if the request was successfully scheduled; false otherwise

The documentation for this class was generated from the following file: