Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
LoadBalancerInterface.hpp
Go to the documentation of this file.
1
2#pragma once
3
4#include "etl/ETLState.hpp"
5#include "etl/InitialLoadObserverInterface.hpp"
6#include "rpc/Errors.hpp"
7
8#include <boost/asio/spawn.hpp>
9#include <boost/json/object.hpp>
10#include <boost/json/value.hpp>
11#include <org/xrpl/rpc/v1/ledger.pb.h>
12#include <xrpl/proto/org/xrpl/rpc/v1/get_ledger.pb.h>
13
14#include <chrono>
15#include <cstdint>
16#include <expected>
17#include <optional>
18#include <string>
19#include <vector>
20
21namespace etl {
22
30
35using InitialLedgerLoadResult = std::expected<std::vector<std::string>, InitialLedgerLoadError>;
36
41public:
45 using RawLedgerObjectType = org::xrpl::rpc::v1::RawLedgerObject;
49 using GetLedgerResponseType = org::xrpl::rpc::v1::GetLedgerResponse;
53 using OptionalGetLedgerResponseType = std::optional<GetLedgerResponseType>;
54
55 virtual ~LoadBalancerInterface() = default;
56
68 [[nodiscard]] virtual InitialLedgerLoadResult
70 uint32_t sequence,
72 std::chrono::steady_clock::duration retryAfter = std::chrono::seconds{2}
73 ) = 0;
74
88 [[nodiscard]] virtual OptionalGetLedgerResponseType
90 uint32_t ledgerSequence,
91 bool getObjects,
92 bool getObjectNeighbors,
93 std::chrono::steady_clock::duration retryAfter = std::chrono::seconds{2}
94 ) = 0;
95
101 [[nodiscard]] virtual boost::json::value
102 toJson() const = 0;
103
113 [[nodiscard]] virtual std::expected<boost::json::object, rpc::CombinedError>
115 boost::json::object const& request,
116 std::optional<std::string> const& clientIp,
117 bool isAdmin,
118 boost::asio::yield_context yield
119 ) = 0;
120
125 [[nodiscard]] virtual std::optional<ETLState>
126 getETLState() noexcept = 0;
127
134 virtual void
135 stop(boost::asio::yield_context yield) = 0;
136};
137
138} // namespace etl
An interface for LoadBalancer.
Definition LoadBalancerInterface.hpp:40
org::xrpl::rpc::v1::RawLedgerObject RawLedgerObjectType
Raw ledger object as received over gRPC.
Definition LoadBalancerInterface.hpp:45
std::optional< GetLedgerResponseType > OptionalGetLedgerResponseType
Optional ledger response, as returned by fetchLedger().
Definition LoadBalancerInterface.hpp:53
virtual std::optional< ETLState > getETLState() noexcept=0
Return state of ETL nodes.
virtual InitialLedgerLoadResult loadInitialLedger(uint32_t sequence, InitialLoadObserverInterface &loader, std::chrono::steady_clock::duration retryAfter=std::chrono::seconds{2})=0
Load the initial ledger, writing data to the queue.
virtual OptionalGetLedgerResponseType fetchLedger(uint32_t ledgerSequence, bool getObjects, bool getObjectNeighbors, std::chrono::steady_clock::duration retryAfter=std::chrono::seconds{2})=0
Fetch data for a specific ledger.
virtual boost::json::value toJson() const =0
Represent the state of this load balancer as a JSON object.
virtual std::expected< boost::json::object, rpc::CombinedError > forwardToRippled(boost::json::object const &request, std::optional< std::string > const &clientIp, bool isAdmin, boost::asio::yield_context yield)=0
Forward a JSON RPC request to a randomly selected rippled node.
org::xrpl::rpc::v1::GetLedgerResponse GetLedgerResponseType
gRPC response containing the data of a single ledger
Definition LoadBalancerInterface.hpp:49
virtual void stop(boost::asio::yield_context yield)=0
Stop the load balancer. This will stop all subscription sources.
This namespace contains everything to do with the ETL and ETL sources.
Definition AmendmentBlockHandlerInterface.hpp:6
InitialLedgerLoadError
Represents possible errors for initial ledger load.
Definition LoadBalancerInterface.hpp:26
@ Errored
Indicating some error happened during initial ledger load.
Definition LoadBalancerInterface.hpp:28
@ Cancelled
Indicating the initial load got cancelled by user.
Definition LoadBalancerInterface.hpp:27
std::expected< std::vector< std::string >, InitialLedgerLoadError > InitialLedgerLoadResult
The result type of the initial ledger load.
Definition LoadBalancerInterface.hpp:35
The interface for observing the initial ledger load.
Definition InitialLoadObserverInterface.hpp:17