57 using OnConnectHook = SourceBase::OnConnectHook;
58 using OnDisconnectHook = SourceBase::OnDisconnectHook;
59 using OnLedgerClosedHook = SourceBase::OnLedgerClosedHook;
64 util::requests::WsConnectionPtr wsConnection_;
66 struct ValidatedLedgersData {
67 std::vector<std::pair<uint32_t, uint32_t>> validatedLedgers;
68 std::string validatedLedgersRaw{
"N/A"};
72 std::shared_ptr<NetworkValidatedLedgersInterface> validatedLedgers_;
73 std::shared_ptr<feed::SubscriptionManagerInterface> subscriptions_;
75 boost::asio::strand<boost::asio::io_context::executor_type> strand_;
77 std::chrono::steady_clock::duration wsTimeout_;
81 OnConnectHook onConnect_;
82 OnDisconnectHook onDisconnect_;
83 OnLedgerClosedHook onLedgerClosed_;
85 std::atomic_bool isConnected_{
false};
86 std::atomic_bool stop_{
false};
87 std::atomic_bool isForwarding_{
false};
91 std::reference_wrapper<util::prometheus::GaugeInt> lastMessageTimeSecondsSinceEpoch_;
95 static constexpr std::chrono::seconds kWS_TIMEOUT{30};
96 static constexpr std::chrono::seconds kRETRY_MAX_DELAY{30};
97 static constexpr std::chrono::seconds kRETRY_DELAY{1};
116 boost::asio::io_context& ioContext,
117 std::string
const& ip,
118 std::string
const& wsPort,
119 std::shared_ptr<NetworkValidatedLedgersInterface> validatedLedgers,
120 std::shared_ptr<feed::SubscriptionManagerInterface> subscriptions,
121 OnConnectHook onConnect,
122 OnDisconnectHook onDisconnect,
123 OnLedgerClosedHook onLedgerClosed,
124 std::chrono::steady_clock::duration
const wsTimeout = SubscriptionSource::kWS_TIMEOUT,
125 std::chrono::steady_clock::duration
const retryDelay = SubscriptionSource::kRETRY_DELAY
174 std::chrono::steady_clock::time_point
189 stop(boost::asio::yield_context yield);
195 std::optional<util::requests::RequestError>
196 handleMessage(std::string
const& message);
205 setLastMessageTime();
208 setValidatedRange(std::string range);
210 static std::string
const&
211 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:149
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:60