Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
WriterDecider.hpp
1#pragma once
2
3#include "cluster/Backend.hpp"
4#include "cluster/ClioNode.hpp"
5#include "cluster/impl/FallbackRecoveryTimer.hpp"
6#include "etl/WriterState.hpp"
7
8#include <boost/asio/thread_pool.hpp>
9
10#include <chrono>
11#include <memory>
12
13namespace cluster {
14
65public:
66 static constexpr std::chrono::steady_clock::duration kRECOVERY_TIME = std::chrono::hours{1};
67
68private:
70 boost::asio::thread_pool& ctx_;
71
73 std::unique_ptr<etl::WriterStateInterface> writerState_;
74
84 impl::FallbackRecoveryTimer fallbackRecoveryTimer_;
85
86public:
96 boost::asio::thread_pool& ctx,
97 std::unique_ptr<etl::WriterStateInterface> writerState,
98 std::chrono::steady_clock::duration recoveryTime = kRECOVERY_TIME
99 );
100
126 void
127 onNewState(ClioNode::CUuid selfId, std::shared_ptr<Backend::ClusterData const> clusterData);
128};
129
130} // namespace cluster
WriterDecider(boost::asio::thread_pool &ctx, std::unique_ptr< etl::WriterStateInterface > writerState, std::chrono::steady_clock::duration recoveryTime=kRECOVERY_TIME)
Constructs a WriterDecider.
Definition WriterDecider.cpp:41
void onNewState(ClioNode::CUuid selfId, std::shared_ptr< Backend::ClusterData const > clusterData)
Handles cluster state changes and decides whether this node should be the writer.
Definition WriterDecider.cpp:51
One-shot timer for fallback recovery, with internal thread-safety.
Definition FallbackRecoveryTimer.hpp:24