Clio develop
The XRP Ledger API server.
|
This class is used to manage connections to transaction processing processes. More...
#include <LoadBalancer.hpp>
Public Member Functions | |
LoadBalancer (util::config::ClioConfigDefinition const &config, boost::asio::io_context &ioc, std::shared_ptr< BackendInterface > backend, std::shared_ptr< feed::SubscriptionManagerInterface > subscriptions, std::shared_ptr< NetworkValidatedLedgersInterface > validatedLedgers, SourceFactory sourceFactory=makeSource) | |
Create an instance of the load balancer. | |
std::vector< std::string > | loadInitialLedger (uint32_t sequence, bool cacheOnly=false, std::chrono::steady_clock::duration retryAfter=std::chrono::seconds{2}) |
Load the initial ledger, writing data to the queue. | |
OptionalGetLedgerResponseType | fetchLedger (uint32_t ledgerSequence, bool getObjects, bool getObjectNeighbors, std::chrono::steady_clock::duration retryAfter=std::chrono::seconds{2}) |
Fetch data for a specific ledger. | |
boost::json::value | toJson () const |
Represent the state of this load balancer as a JSON object. | |
std::expected< boost::json::object, rpc::ClioError > | forwardToRippled (boost::json::object const &request, std::optional< std::string > const &clientIp, bool isAdmin, boost::asio::yield_context yield) |
Forward a JSON RPC request to a randomly selected rippled node. | |
std::optional< ETLState > | getETLState () noexcept |
Return state of ETL nodes. | |
void | stop (boost::asio::yield_context yield) |
Stop the load balancer. This will stop all subscription sources. | |
![]() |
Static Public Member Functions | |
static std::shared_ptr< LoadBalancer > | makeLoadBalancer (util::config::ClioConfigDefinition const &config, boost::asio::io_context &ioc, std::shared_ptr< BackendInterface > backend, std::shared_ptr< feed::SubscriptionManagerInterface > subscriptions, std::shared_ptr< NetworkValidatedLedgersInterface > validatedLedgers, SourceFactory sourceFactory=makeSource) |
A factory function for the load balancer. | |
This class is used to manage connections to transaction processing processes.
This class spawns a listener for each etl source, which listens to messages on the ledgers stream (to keep track of which ledgers have been validated by the network, and the range of ledgers each etl source has). This class also allows requests for ledger data to be load balanced across all possible ETL sources.
etl::LoadBalancer::LoadBalancer | ( | util::config::ClioConfigDefinition const & | config, |
boost::asio::io_context & | ioc, | ||
std::shared_ptr< BackendInterface > | backend, | ||
std::shared_ptr< feed::SubscriptionManagerInterface > | subscriptions, | ||
std::shared_ptr< NetworkValidatedLedgersInterface > | validatedLedgers, | ||
SourceFactory | sourceFactory = makeSource ) |
Create an instance of the load balancer.
config | The configuration to use |
ioc | The io_context to run on |
backend | BackendInterface implementation |
subscriptions | Subscription manager |
validatedLedgers | The network validated ledgers datastructure |
sourceFactory | A factory function to create a source |
LoadBalancer::OptionalGetLedgerResponseType etl::LoadBalancer::fetchLedger | ( | uint32_t | ledgerSequence, |
bool | getObjects, | ||
bool | getObjectNeighbors, | ||
std::chrono::steady_clock::duration | retryAfter = std::chrono::seconds{2} ) |
Fetch data for a specific ledger.
This function will continuously try to fetch data for the specified ledger until the fetch succeeds, the ledger is found in the database, or the server is shutting down.
ledgerSequence | Sequence of the ledger to fetch |
getObjects | Whether to get the account state diff between this ledger and the prior one |
getObjectNeighbors | Whether to request object neighbors |
retryAfter | Time to wait between retries (2 seconds by default) |
std::expected< boost::json::object, rpc::ClioError > etl::LoadBalancer::forwardToRippled | ( | boost::json::object const & | request, |
std::optional< std::string > const & | clientIp, | ||
bool | isAdmin, | ||
boost::asio::yield_context | yield ) |
Forward a JSON RPC request to a randomly selected rippled node.
request | JSON-RPC request to forward |
clientIp | The IP address of the peer, if known |
isAdmin | Whether the request is from an admin |
yield | The coroutine context |
|
noexcept |
Return state of ETL nodes.
std::vector< std::string > etl::LoadBalancer::loadInitialLedger | ( | uint32_t | sequence, |
bool | cacheOnly = false, | ||
std::chrono::steady_clock::duration | retryAfter = std::chrono::seconds{2} ) |
Load the initial ledger, writing data to the queue.
sequence | Sequence of ledger to download |
cacheOnly | Whether to only write to cache and not to the DB; defaults to false |
retryAfter | Time to wait between retries (2 seconds by default) |
|
static |
A factory function for the load balancer.
config | The configuration to use |
ioc | The io_context to run on |
backend | BackendInterface implementation |
subscriptions | Subscription manager |
validatedLedgers | The network validated ledgers datastructure |
sourceFactory | A factory function to create a source |
void etl::LoadBalancer::stop | ( | boost::asio::yield_context | yield | ) |
Stop the load balancer. This will stop all subscription sources.
yield | The coroutine context |
boost::json::value etl::LoadBalancer::toJson | ( | ) | const |
Represent the state of this load balancer as a JSON object.