Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
MonitorInterface.hpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of clio: https://github.com/XRPLF/clio
4 Copyright (c) 2025, the clio developers.
5
6 Permission to use, copy, modify, and distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#pragma once
21
22#include <boost/signals2/connection.hpp>
23#include <boost/signals2/signal.hpp>
24#include <boost/signals2/variadic_signal.hpp>
25
26#include <chrono>
27#include <cstdint>
28
29namespace etlng {
30
37public:
38 static constexpr auto kDEFAULT_REPEAT_INTERVAL = std::chrono::seconds{1};
39 using NewSequenceSignalType = boost::signals2::signal<void(uint32_t)>;
40 using DbStalledSignalType = boost::signals2::signal<void()>;
41
42 virtual ~MonitorInterface() = default;
43
48 virtual void
49 notifySequenceLoaded(uint32_t seq) = 0;
50
55 virtual void
56 notifyWriteConflict(uint32_t seq) = 0;
57
64 [[nodiscard]] virtual boost::signals2::scoped_connection
65 subscribeToNewSequence(NewSequenceSignalType::slot_type const& subscriber) = 0;
66
73 [[nodiscard]] virtual boost::signals2::scoped_connection
74 subscribeToDbStalled(DbStalledSignalType::slot_type const& subscriber) = 0;
75
81 virtual void
82 run(std::chrono::steady_clock::duration repeatInterval = kDEFAULT_REPEAT_INTERVAL) = 0;
83
87 virtual void
88 stop() = 0;
89};
90
91} // namespace etlng
An interface for the monitor service An implementation of this service is responsible for periodicall...
Definition MonitorInterface.hpp:36
virtual void run(std::chrono::steady_clock::duration repeatInterval=kDEFAULT_REPEAT_INTERVAL)=0
Run the monitor service.
virtual void notifyWriteConflict(uint32_t seq)=0
Notifies the monitor of a write conflict.
virtual void stop()=0
Stops the monitor service.
virtual void notifySequenceLoaded(uint32_t seq)=0
Allows the loading process to notify of a freshly committed ledger.
virtual boost::signals2::scoped_connection subscribeToNewSequence(NewSequenceSignalType::slot_type const &subscriber)=0
Allows clients to get notified when a new ledger becomes available in Clio's database.
virtual boost::signals2::scoped_connection subscribeToDbStalled(DbStalledSignalType::slot_type const &subscriber)=0
Allows clients to get notified when no database update is detected for a configured period.