|
Clio
develop
The XRP Ledger API server.
|
Backend communication handler for cluster state synchronization. More...
#include <Backend.hpp>
Public Types | |
| using | ClusterData = std::expected<std::vector<ClioNode>, std::string> |
| Type representing cluster data result - either a vector of nodes or an error message. | |
Public Member Functions | |
| Backend (boost::asio::thread_pool &ctx, std::shared_ptr< data::BackendInterface > backend, std::unique_ptr< etl::WriterStateInterface const > writerState, std::chrono::steady_clock::duration readInterval, std::chrono::steady_clock::duration writeInterval) | |
| Construct a Backend communication handler. | |
| Backend (Backend &&)=delete | |
| Backend & | operator= (Backend &&)=delete |
| Backend (Backend const &)=delete | |
| Backend & | operator= (Backend const &)=delete |
| void | run () |
| Start the backend read and write tasks. | |
| void | stop () |
| Stop the backend read and write tasks. | |
| template<typename S> | |
| boost::signals2::connection | subscribeToNewState (S &&s) |
| Subscribe to new cluster state notifications. | |
| ClioNode::CUuid | selfId () const |
| Get the UUID of this node in the cluster. | |
Backend communication handler for cluster state synchronization.
This class manages reading and writing cluster state information to/from the backend database. It periodically reads the state of other nodes in the cluster and writes the current node's state, enabling cluster-wide coordination and awareness.
| cluster::Backend::Backend | ( | boost::asio::thread_pool & | ctx, |
| std::shared_ptr< data::BackendInterface > | backend, | ||
| std::unique_ptr< etl::WriterStateInterface const > | writerState, | ||
| std::chrono::steady_clock::duration | readInterval, | ||
| std::chrono::steady_clock::duration | writeInterval ) |
Construct a Backend communication handler.
| ctx | The execution context for asynchronous operations |
| backend | Interface to the backend database |
| writerState | State indicating whether this node is writing to the database |
| readInterval | How often to read cluster state from the backend |
| writeInterval | How often to write this node's state to the backend |
| void cluster::Backend::run | ( | ) |
Start the backend read and write tasks.
Begins periodic reading of cluster state from the backend and writing of this node's state.
| ClioNode::CUuid cluster::Backend::selfId | ( | ) | const |
Get the UUID of this node in the cluster.
| void cluster::Backend::stop | ( | ) |
Stop the backend read and write tasks.
Stops all periodic tasks and waits for them to complete.
|
inline |
Subscribe to new cluster state notifications.
| S | Callable type accepting (ClioNode::cUUID, ClusterData) |
| s | Subscriber callback to be invoked when new cluster state is available |