This class is used to subscribe to a source of ledger data and forward it to the subscription manager.
More...
#include <SubscriptionSource.hpp>
|
|
using | OnConnectHook = SourceBase::OnConnectHook |
|
using | OnDisconnectHook = SourceBase::OnDisconnectHook |
|
using | OnLedgerClosedHook = SourceBase::OnLedgerClosedHook |
|
| | SubscriptionSource (boost::asio::io_context &ioContext, std::string const &ip, std::string const &wsPort, std::shared_ptr< NetworkValidatedLedgersInterface > validatedLedgers, std::shared_ptr< feed::SubscriptionManagerInterface > subscriptions, OnConnectHook onConnect, OnDisconnectHook onDisconnect, OnLedgerClosedHook onLedgerClosed, std::chrono::steady_clock::duration const wsTimeout=SubscriptionSource::kWS_TIMEOUT, std::chrono::steady_clock::duration const retryDelay=SubscriptionSource::kRETRY_DELAY) |
| | Construct a new Subscription Source object.
|
|
void | run () |
| | Run the source.
|
| bool | hasLedger (uint32_t sequence) const |
| | Check if the source has a ledger.
|
| bool | isConnected () const |
| | Check if the source is connected.
|
| bool | isForwarding () const |
| | Get whether the source is forwarding.
|
| void | setForwarding (bool isForwarding) |
| | Set source forwarding.
|
| std::chrono::steady_clock::time_point | lastMessageTime () const |
| | Get the last message time (even if the last message had an error).
|
| std::string const & | validatedRange () const |
| | Get the last received raw string of the validated ledgers.
|
|
void | stop (boost::asio::yield_context yield) |
| | Stop the source. The source will complete already scheduled operations but will not schedule new ones.
|
This class is used to subscribe to a source of ledger data and forward it to the subscription manager.
- Note
- This class is safe to delete only if io_context is stopped.
◆ SubscriptionSource()
| etl::impl::SubscriptionSource::SubscriptionSource |
( |
boost::asio::io_context & | ioContext, |
|
|
std::string const & | ip, |
|
|
std::string const & | wsPort, |
|
|
std::shared_ptr< NetworkValidatedLedgersInterface > | validatedLedgers, |
|
|
std::shared_ptr< feed::SubscriptionManagerInterface > | subscriptions, |
|
|
OnConnectHook | onConnect, |
|
|
OnDisconnectHook | onDisconnect, |
|
|
OnLedgerClosedHook | onLedgerClosed, |
|
|
std::chrono::steady_clock::duration const | wsTimeout = SubscriptionSource::kWS_TIMEOUT, |
|
|
std::chrono::steady_clock::duration const | retryDelay = SubscriptionSource::kRETRY_DELAY ) |
Construct a new Subscription Source object.
- Template Parameters
-
| NetworkValidatedLedgersType | The type of the network validated ledgers object |
- Parameters
-
| ioContext | The io_context to use |
| ip | The ip address of the source |
| wsPort | The port of the source |
| validatedLedgers | The network validated ledgers object |
| subscriptions | The subscription manager object |
| onConnect | The onConnect hook. Called when the connection is established |
| onDisconnect | The onDisconnect hook. Called when the connection is lost |
| onLedgerClosed | The onLedgerClosed hook. Called when the ledger is closed if the source is forwarding |
| wsTimeout | A timeout for websocket operations. Defaults to 30 seconds |
| retryDelay | The retry delay. Defaults to 1 second |
◆ hasLedger()
| bool etl::impl::SubscriptionSource::hasLedger |
( |
uint32_t | sequence | ) |
const |
Check if the source has a ledger.
- Parameters
-
| sequence | The sequence of the ledger |
- Returns
- true if the source has the ledger, false otherwise
◆ isConnected()
| bool etl::impl::SubscriptionSource::isConnected |
( |
| ) |
const |
Check if the source is connected.
- Returns
- true if the source is connected, false otherwise
◆ isForwarding()
| bool etl::impl::SubscriptionSource::isForwarding |
( |
| ) |
const |
Get whether the source is forwarding.
- Returns
- true if the source is forwarding, false otherwise
◆ lastMessageTime()
| std::chrono::steady_clock::time_point etl::impl::SubscriptionSource::lastMessageTime |
( |
| ) |
const |
Get the last message time (even if the last message had an error).
- Returns
- The last message time
◆ setForwarding()
| void etl::impl::SubscriptionSource::setForwarding |
( |
bool | isForwarding | ) |
|
Set source forwarding.
- Note
- If forwarding is true the source will forward messages to the subscription manager. Forwarding is being reset on disconnect.
- Parameters
-
| isForwarding | The new forwarding state |
◆ validatedRange()
| std::string const & etl::impl::SubscriptionSource::validatedRange |
( |
| ) |
const |
Get the last received raw string of the validated ledgers.
- Returns
- The validated ledgers string
The documentation for this class was generated from the following files: