Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
etlng::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType > Class Template Reference

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

#include <SourceImpl.hpp>

Inheritance diagram for etlng::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType >:
Collaboration diagram for etlng::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType >:

Public Member Functions

template<typename SomeGrpcSourceType , typename SomeForwardingSourceType >
requires std::is_same_v<GrpcSourceType, SomeGrpcSourceType> and std::is_same_v<ForwardingSourceType, SomeForwardingSourceType>
 SourceImpl (std::string ip, std::string wsPort, std::string grpcPort, SomeGrpcSourceType &&grpcSource, SubscriptionSourceTypePtr subscriptionSource, SomeForwardingSourceType &&forwardingSource)
 Construct a new SourceImpl object.
 
void run () final
 Run subscriptions loop of the source.
 
void stop (boost::asio::yield_context yield) final
 Stop Source.
 
bool isConnected () const final
 Check if source is connected.
 
void setForwarding (bool isForwarding) final
 Set the forwarding state of the source.
 
boost::json::object toJson () const final
 Represent the source as a JSON object.
 
std::string toString () const final
 
bool hasLedger (uint32_t sequence) const final
 Check if ledger is known by this source.
 
std::pair< grpc::Status, org::xrpl::rpc::v1::GetLedgerResponse > fetchLedger (uint32_t sequence, bool getObjects=true, bool getObjectNeighbors=false) final
 Fetch data for a specific ledger.
 
std::pair< std::vector< std::string >, bool > loadInitialLedger (uint32_t sequence, std::uint32_t numMarkers, etlng::InitialLoadObserverInterface &loader) final
 Download a ledger in full.
 
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 final
 Forward a request to rippled.
 
- Public Member Functions inherited from etlng::SourceBase

Additional Inherited Members

- Public Types inherited from etlng::SourceBase
using OnConnectHook = std::function<void()>
 
using OnDisconnectHook = std::function<void(bool)>
 
using OnLedgerClosedHook = std::function<void()>
 

Detailed Description

template<typename GrpcSourceType = GrpcSource, typename SubscriptionSourceTypePtr = std::unique_ptr<etl::impl::SubscriptionSource>, typename ForwardingSourceType = etl::impl::ForwardingSource>
class etlng::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType >

Provides an implementation of a ETL source.

Template Parameters
GrpcSourceTypeThe type of the gRPC source
SubscriptionSourceTypePtrThe type of the subscription source
ForwardingSourceTypeThe type of the forwarding source

Constructor & Destructor Documentation

◆ SourceImpl()

template<typename GrpcSourceType = GrpcSource, typename SubscriptionSourceTypePtr = std::unique_ptr<etl::impl::SubscriptionSource>, typename ForwardingSourceType = etl::impl::ForwardingSource>
template<typename SomeGrpcSourceType , typename SomeForwardingSourceType >
requires std::is_same_v<GrpcSourceType, SomeGrpcSourceType> and std::is_same_v<ForwardingSourceType, SomeForwardingSourceType>
etlng::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType >::SourceImpl ( std::string ip,
std::string wsPort,
std::string grpcPort,
SomeGrpcSourceType && grpcSource,
SubscriptionSourceTypePtr subscriptionSource,
SomeForwardingSourceType && forwardingSource )
inline

Construct a new SourceImpl object.

Parameters
ipThe IP of the source
wsPortThe web socket port of the source
grpcPortThe gRPC port of the source
grpcSourceThe gRPC source
subscriptionSourceThe subscription source
forwardingSourceThe forwarding source

Member Function Documentation

◆ fetchLedger()

template<typename GrpcSourceType = GrpcSource, typename SubscriptionSourceTypePtr = std::unique_ptr<etl::impl::SubscriptionSource>, typename ForwardingSourceType = etl::impl::ForwardingSource>
std::pair< grpc::Status, org::xrpl::rpc::v1::GetLedgerResponse > etlng::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType >::fetchLedger ( uint32_t sequence,
bool getObjects = true,
bool getObjectNeighbors = false )
inlinefinalvirtual

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

Implements etlng::SourceBase.

◆ forwardToRippled()

template<typename GrpcSourceType = GrpcSource, typename SubscriptionSourceTypePtr = std::unique_ptr<etl::impl::SubscriptionSource>, typename ForwardingSourceType = etl::impl::ForwardingSource>
std::expected< boost::json::object, rpc::ClioError > etlng::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType >::forwardToRippled ( boost::json::object const & request,
std::optional< std::string > const & forwardToRippledClientIp,
std::string_view xUserValue,
boost::asio::yield_context yield ) const
inlinefinalvirtual

Forward a request to rippled.

Parameters
requestThe request to forward
forwardToRippledClientIpIP of the client forwarding this request if known
xUserValueOptional value of the X-User header
yieldThe coroutine context
Returns
Response or ClioError

Implements etlng::SourceBase.

◆ hasLedger()

template<typename GrpcSourceType = GrpcSource, typename SubscriptionSourceTypePtr = std::unique_ptr<etl::impl::SubscriptionSource>, typename ForwardingSourceType = etl::impl::ForwardingSource>
bool etlng::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType >::hasLedger ( uint32_t sequence) const
inlinefinalvirtual

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

Implements etlng::SourceBase.

◆ isConnected()

template<typename GrpcSourceType = GrpcSource, typename SubscriptionSourceTypePtr = std::unique_ptr<etl::impl::SubscriptionSource>, typename ForwardingSourceType = etl::impl::ForwardingSource>
bool etlng::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType >::isConnected ( ) const
inlinefinalvirtual

Check if source is connected.

Returns
true if source is connected; false otherwise

Implements etlng::SourceBase.

◆ loadInitialLedger()

template<typename GrpcSourceType = GrpcSource, typename SubscriptionSourceTypePtr = std::unique_ptr<etl::impl::SubscriptionSource>, typename ForwardingSourceType = etl::impl::ForwardingSource>
std::pair< std::vector< std::string >, bool > etlng::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType >::loadInitialLedger ( uint32_t sequence,
std::uint32_t numMarkers,
etlng::InitialLoadObserverInterface & loader )
inlinefinalvirtual

Download a ledger in full.

Parameters
sequenceSequence of the ledger to download
numMarkersNumber of markers to generate for async calls
loaderInitialLoadObserverInterface implementation
Returns
A std::pair of the data and a bool indicating whether the download was successful

Implements etlng::SourceBase.

◆ run()

template<typename GrpcSourceType = GrpcSource, typename SubscriptionSourceTypePtr = std::unique_ptr<etl::impl::SubscriptionSource>, typename ForwardingSourceType = etl::impl::ForwardingSource>
void etlng::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType >::run ( )
inlinefinalvirtual

Run subscriptions loop of the source.

Implements etlng::SourceBase.

◆ setForwarding()

template<typename GrpcSourceType = GrpcSource, typename SubscriptionSourceTypePtr = std::unique_ptr<etl::impl::SubscriptionSource>, typename ForwardingSourceType = etl::impl::ForwardingSource>
void etlng::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType >::setForwarding ( bool isForwarding)
inlinefinalvirtual

Set the forwarding state of the source.

Parameters
isForwardingWhether to forward or not

Implements etlng::SourceBase.

◆ stop()

template<typename GrpcSourceType = GrpcSource, typename SubscriptionSourceTypePtr = std::unique_ptr<etl::impl::SubscriptionSource>, typename ForwardingSourceType = etl::impl::ForwardingSource>
void etlng::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType >::stop ( boost::asio::yield_context yield)
inlinefinalvirtual

Stop Source.

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

Implements etlng::SourceBase.

◆ toJson()

template<typename GrpcSourceType = GrpcSource, typename SubscriptionSourceTypePtr = std::unique_ptr<etl::impl::SubscriptionSource>, typename ForwardingSourceType = etl::impl::ForwardingSource>
boost::json::object etlng::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType >::toJson ( ) const
inlinefinalvirtual

Represent the source as a JSON object.

Returns
JSON representation of the source

Implements etlng::SourceBase.

◆ toString()

template<typename GrpcSourceType = GrpcSource, typename SubscriptionSourceTypePtr = std::unique_ptr<etl::impl::SubscriptionSource>, typename ForwardingSourceType = etl::impl::ForwardingSource>
std::string etlng::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType >::toString ( ) const
inlinefinalvirtual
Returns
String representation of the source (for debug)

Implements etlng::SourceBase.


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