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

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

#include <SourceImpl.hpp>

Inheritance diagram for etl::impl::SourceImpl< GrpcSourceType, SubscriptionSourceTypePtr, ForwardingSourceType >:
Collaboration diagram for etl::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, bool cacheOnly=false) 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 etl::SourceBase

Additional Inherited Members

- Public Types inherited from etl::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<SubscriptionSource>, typename ForwardingSourceType = ForwardingSource>
class etl::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<SubscriptionSource>, typename ForwardingSourceType = ForwardingSource>
template<typename SomeGrpcSourceType , typename SomeForwardingSourceType >
requires std::is_same_v<GrpcSourceType, SomeGrpcSourceType> and std::is_same_v<ForwardingSourceType, SomeForwardingSourceType>
etl::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<SubscriptionSource>, typename ForwardingSourceType = ForwardingSource>
std::pair< grpc::Status, org::xrpl::rpc::v1::GetLedgerResponse > etl::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 etl::SourceBase.

◆ forwardToRippled()

template<typename GrpcSourceType = GrpcSource, typename SubscriptionSourceTypePtr = std::unique_ptr<SubscriptionSource>, typename ForwardingSourceType = ForwardingSource>
std::expected< boost::json::object, rpc::ClioError > etl::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 etl::SourceBase.

◆ hasLedger()

template<typename GrpcSourceType = GrpcSource, typename SubscriptionSourceTypePtr = std::unique_ptr<SubscriptionSource>, typename ForwardingSourceType = ForwardingSource>
bool etl::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 etl::SourceBase.

◆ isConnected()

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

Check if source is connected.

Returns
true if source is connected; false otherwise

Implements etl::SourceBase.

◆ loadInitialLedger()

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

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

Implements etl::SourceBase.

◆ run()

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

Run subscriptions loop of the source.

Implements etl::SourceBase.

◆ setForwarding()

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

Set the forwarding state of the source.

Parameters
isForwardingWhether to forward or not

Implements etl::SourceBase.

◆ stop()

template<typename GrpcSourceType = GrpcSource, typename SubscriptionSourceTypePtr = std::unique_ptr<SubscriptionSource>, typename ForwardingSourceType = ForwardingSource>
void etl::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 etl::SourceBase.

◆ toJson()

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

Represent the source as a JSON object.

Returns
JSON representation of the source

Implements etl::SourceBase.

◆ toString()

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

Implements etl::SourceBase.


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