Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
cluster::Backend Class Reference

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
Backendoperator= (Backend &&)=delete
 Backend (Backend const &)=delete
Backendoperator= (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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ Backend()

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.

Parameters
ctxThe execution context for asynchronous operations
backendInterface to the backend database
writerStateState indicating whether this node is writing to the database
readIntervalHow often to read cluster state from the backend
writeIntervalHow often to write this node's state to the backend

Member Function Documentation

◆ run()

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.

◆ selfId()

ClioNode::CUuid cluster::Backend::selfId ( ) const

Get the UUID of this node in the cluster.

Returns
The UUID of this node.

◆ stop()

void cluster::Backend::stop ( )

Stop the backend read and write tasks.

Stops all periodic tasks and waits for them to complete.

◆ subscribeToNewState()

template<typename S>
boost::signals2::connection cluster::Backend::subscribeToNewState ( S && s)
inline

Subscribe to new cluster state notifications.

Template Parameters
SCallable type accepting (ClioNode::cUUID, ClusterData)
Parameters
sSubscriber callback to be invoked when new cluster state is available
Returns
A connection object that can be used to unsubscribe

The documentation for this class was generated from the following files:
  • /__w/clio/clio/src/cluster/Backend.hpp
  • /__w/clio/clio/src/cluster/Backend.cpp