58 using OnConnectHook = SourceBase::OnConnectHook;
59 using OnDisconnectHook = SourceBase::OnDisconnectHook;
60 using OnLedgerClosedHook = SourceBase::OnLedgerClosedHook;
65 util::requests::WsConnectionPtr wsConnection_;
67 struct ValidatedLedgersData {
68 std::vector<std::pair<uint32_t, uint32_t>> validatedLedgers;
69 std::string validatedLedgersRaw{
"N/A"};
73 std::shared_ptr<NetworkValidatedLedgersInterface> validatedLedgers_;
74 std::shared_ptr<feed::SubscriptionManagerInterface> subscriptions_;
76 boost::asio::strand<boost::asio::io_context::executor_type> strand_;
78 std::chrono::steady_clock::duration wsTimeout_;
82 OnConnectHook onConnect_;
83 OnDisconnectHook onDisconnect_;
84 OnLedgerClosedHook onLedgerClosed_;
86 std::atomic_bool isConnected_{
false};
87 std::atomic_bool stop_{
false};
88 std::atomic_bool isForwarding_{
false};
92 std::reference_wrapper<util::prometheus::GaugeInt> lastMessageTimeSecondsSinceEpoch_;
96 static constexpr std::chrono::seconds kWS_TIMEOUT{30};
97 static constexpr std::chrono::seconds kRETRY_MAX_DELAY{30};
98 static constexpr std::chrono::seconds kRETRY_DELAY{1};
118 boost::asio::io_context& ioContext,
119 std::string
const& ip,
120 std::string
const& wsPort,
121 std::shared_ptr<NetworkValidatedLedgersInterface> validatedLedgers,
122 std::shared_ptr<feed::SubscriptionManagerInterface> subscriptions,
123 OnConnectHook onConnect,
124 OnDisconnectHook onDisconnect,
125 OnLedgerClosedHook onLedgerClosed,
126 std::chrono::steady_clock::duration
const wsTimeout = SubscriptionSource::kWS_TIMEOUT,
127 std::chrono::steady_clock::duration
const retryDelay = SubscriptionSource::kRETRY_DELAY
176 std::chrono::steady_clock::time_point
192 stop(boost::asio::yield_context yield);
198 std::optional<util::requests::RequestError>
199 handleMessage(std::string
const& message);
208 setLastMessageTime();
211 setValidatedRange(std::string range);
213 static std::string
const&
214 getSubscribeCommandJson();
void stop(boost::asio::yield_context yield)
Stop the source. The source will complete already scheduled operations but will not schedule new ones...
Definition SubscriptionSource.cpp:153
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.
Definition SubscriptionSource.cpp:62