Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
etl::SourceBase Class Referenceabstract

Provides an implementation of a ETL source. More...

#include <Source.hpp>

Inheritance diagram for etl::SourceBase:

Public Types

using OnConnectHook = std::function<void()>
 
using OnDisconnectHook = std::function<void(bool)>
 
using OnLedgerClosedHook = std::function<void()>
 

Public Member Functions

virtual void run ()=0
 Run subscriptions loop of the source.
 
virtual void stop (boost::asio::yield_context yield)=0
 Stop Source.
 
virtual bool isConnected () const =0
 Check if source is connected.
 
virtual void setForwarding (bool isForwarding)=0
 Set the forwarding state of the source.
 
virtual boost::json::object toJson () const =0
 Represent the source as a JSON object.
 
virtual std::string toString () const =0
 
virtual bool hasLedger (uint32_t sequence) const =0
 Check if ledger is known by this source.
 
virtual std::pair< grpc::Status, org::xrpl::rpc::v1::GetLedgerResponse > fetchLedger (uint32_t sequence, bool getObjects=true, bool getObjectNeighbors=false)=0
 Fetch data for a specific ledger.
 
virtual std::pair< std::vector< std::string >, bool > loadInitialLedger (uint32_t sequence, std::uint32_t numMarkers, bool cacheOnly=false)=0
 Download a ledger in full.
 
virtual std::expected< boost::json::object, rpc::ClioErrorforwardToRippled (boost::json::object const &request, std::optional< std::string > const &forwardToRippledClientIp, std::string_view xUserValue, boost::asio::yield_context yield) const =0
 Forward a request to rippled.
 

Detailed Description

Provides an implementation of a ETL source.

Member Function Documentation

◆ fetchLedger()

virtual std::pair< grpc::Status, org::xrpl::rpc::v1::GetLedgerResponse > etl::SourceBase::fetchLedger ( uint32_t sequence,
bool getObjects = true,
bool getObjectNeighbors = false )
pure virtual

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.

Parameters
sequenceSequence of the ledger to fetch
getObjectsWhether to get the account state diff between this ledger and the prior one; defaults to true
getObjectNeighborsWhether to request object neighbors; defaults to false
Returns
A std::pair of the response status and the response itself

Implemented in etl::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType >.

◆ forwardToRippled()

virtual std::expected< boost::json::object, rpc::ClioError > etl::SourceBase::forwardToRippled ( boost::json::object const & request,
std::optional< std::string > const & forwardToRippledClientIp,
std::string_view xUserValue,
boost::asio::yield_context yield ) const
pure virtual

Forward a request to rippled.

Parameters
requestThe request to forward
forwardToRippledClientIpIP of the client forwarding this request if known
xUserValueValue of the X-User header
yieldThe coroutine context
Returns
Response on success or error on failure

Implemented in etl::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType >.

◆ hasLedger()

virtual bool etl::SourceBase::hasLedger ( uint32_t sequence) const
pure virtual

Check if ledger is known by this source.

Parameters
sequenceThe ledger sequence to check
Returns
true if ledger is in the range of this source; false otherwise

Implemented in etl::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType >.

◆ isConnected()

virtual bool etl::SourceBase::isConnected ( ) const
pure virtual

Check if source is connected.

Returns
true if source is connected; false otherwise

Implemented in etl::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType >.

◆ loadInitialLedger()

virtual std::pair< std::vector< std::string >, bool > etl::SourceBase::loadInitialLedger ( uint32_t sequence,
std::uint32_t numMarkers,
bool cacheOnly = false )
pure virtual

Download a ledger in full.

Parameters
sequenceSequence of the ledger to download
numMarkersNumber of markers to generate for async calls
cacheOnlyOnly insert into cache, not the DB; defaults to false
Returns
A std::pair of the data and a bool indicating whether the download was successful

Implemented in etl::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType >.

◆ run()

virtual void etl::SourceBase::run ( )
pure virtual

◆ setForwarding()

virtual void etl::SourceBase::setForwarding ( bool isForwarding)
pure virtual

Set the forwarding state of the source.

Parameters
isForwardingWhether to forward or not

Implemented in etl::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType >.

◆ stop()

virtual void etl::SourceBase::stop ( boost::asio::yield_context yield)
pure virtual

Stop Source.

Note
This method will asynchronously wait for source to be stopped.
Parameters
yieldThe coroutine context.

Implemented in etl::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType >.

◆ toJson()

virtual boost::json::object etl::SourceBase::toJson ( ) const
pure virtual

Represent the source as a JSON object.

Returns
JSON representation of the source

Implemented in etl::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType >.

◆ toString()

virtual std::string etl::SourceBase::toString ( ) const
pure virtual
Returns
String representation of the source (for debug)

Implemented in etl::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType >.


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