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:
69 static constexpr std::chrono::steady_clock::duration kRecoveryTime = std::chrono::hours{1};
70
71private:
75 boost::asio::thread_pool& ctx_;
76
80 std::unique_ptr<etl::WriterStateInterface> writerState_;
81
91 impl::FallbackRecoveryTimer fallbackRecoveryTimer_;
92
93public:
103 boost::asio::thread_pool& ctx,
104 std::unique_ptr<etl::WriterStateInterface> writerState,
105 std::chrono::steady_clock::duration recoveryTime = kRecoveryTime
106 );
107
133 void
134 onNewState(ClioNode::CUuid selfId, std::shared_ptr<Backend::ClusterData const> clusterData);
135};
136
137} // namespace cluster
WriterDecider(boost::asio::thread_pool &ctx, std::unique_ptr< etl::WriterStateInterface > writerState, std::chrono::steady_clock::duration recoveryTime=kRecoveryTime)
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
static constexpr std::chrono::steady_clock::duration kRecoveryTime
Default time spent in Fallback before attempting to recover to election mode.
Definition WriterDecider.hpp:69
One-shot timer for fallback recovery, with internal thread-safety.
Definition FallbackRecoveryTimer.hpp:24
This namespace implements cluster coordination between Clio nodes.
Definition Backend.cpp:24
std::shared_ptr< boost::uuids::uuid const > CUuid
Shared read-only node UUID.
Definition ClioNode.hpp:50