39 using OnConnectHook = SourceBase::OnConnectHook;
40 using OnDisconnectHook = SourceBase::OnDisconnectHook;
41 using OnLedgerClosedHook = SourceBase::OnLedgerClosedHook;
46 util::requests::WsConnectionPtr wsConnection_;
48 struct ValidatedLedgersData {
49 std::vector<std::pair<uint32_t, uint32_t>> validatedLedgers;
50 std::string validatedLedgersRaw{
"N/A"};
54 std::shared_ptr<NetworkValidatedLedgersInterface> validatedLedgers_;
55 std::shared_ptr<feed::SubscriptionManagerInterface> subscriptions_;
57 boost::asio::strand<boost::asio::io_context::executor_type> strand_;
59 std::chrono::steady_clock::duration wsTimeout_;
63 OnConnectHook onConnect_;
64 OnDisconnectHook onDisconnect_;
65 OnLedgerClosedHook onLedgerClosed_;
67 std::atomic_bool isConnected_{
false};
68 std::atomic_bool stop_{
false};
69 std::atomic_bool isForwarding_{
false};
73 std::reference_wrapper<util::prometheus::GaugeInt> lastMessageTimeSecondsSinceEpoch_;
77 static constexpr std::chrono::seconds kWS_TIMEOUT{30};
78 static constexpr std::chrono::seconds kRETRY_MAX_DELAY{30};
79 static constexpr std::chrono::seconds kRETRY_DELAY{1};
99 boost::asio::io_context& ioContext,
100 std::string
const& ip,
101 std::string
const& wsPort,
102 std::shared_ptr<NetworkValidatedLedgersInterface> validatedLedgers,
103 std::shared_ptr<feed::SubscriptionManagerInterface> subscriptions,
104 OnConnectHook onConnect,
105 OnDisconnectHook onDisconnect,
106 OnLedgerClosedHook onLedgerClosed,
107 std::chrono::steady_clock::duration
const wsTimeout = SubscriptionSource::kWS_TIMEOUT,
108 std::chrono::steady_clock::duration
const retryDelay = SubscriptionSource::kRETRY_DELAY
157 std::chrono::steady_clock::time_point
173 stop(boost::asio::yield_context yield);
179 std::optional<util::requests::RequestError>
180 handleMessage(std::string
const& message);
189 setLastMessageTime();
192 setValidatedRange(std::string range);
194 static std::string
const&
195 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:134
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:43