6#ifndef OPENCBDC_TX_SRC_RAFT_NODE_H_
7#define OPENCBDC_TX_SRC_RAFT_NODE_H_
14#include <libnuraft/nuraft.hxx>
18 using result_type = nuraft::cmd_result<nuraft::ptr<nuraft::buffer>>;
23 nuraft::ptr<std::exception>& err)>;
55 std::vector<network::endpoint_t> raft_endpoints,
56 const std::string& node_type,
58 nuraft::ptr<nuraft::state_machine> sm,
59 size_t asio_thread_pool_size,
60 std::shared_ptr<logging::log> logger,
61 nuraft::cb_func::func_type raft_cb);
69 auto init(
const nuraft::raft_params& raft_params) -> bool;
73 [[nodiscard]]
auto is_leader() const ->
bool;
93 -> std::optional<nuraft::ptr<nuraft::
buffer>>;
102 [[nodiscard]] auto
get_sm() const -> nuraft::state_machine*;
112 nuraft::ptr<nuraft::logger> m_raft_logger;
114 nuraft::ptr<nuraft::state_machine> m_sm;
115 nuraft::raft_launcher m_launcher;
116 nuraft::ptr<nuraft::raft_server> m_raft_instance;
118 nuraft::asio_service::options m_asio_opt;
119 nuraft::raft_server::init_options m_init_opts;
121 std::shared_ptr<logging::log> m_log;
Buffer to store and retrieve byte data.
A node in a raft cluster.
void stop()
Shut down the NuRaft instance.
auto replicate(nuraft::ptr< nuraft::buffer > new_log, const callback_type &result_fn) const -> bool
Replicates the given log entry in the cluster.
auto get_sm() const -> nuraft::state_machine *
Returns a pointer to the state machine replicated by this raft node.
auto init(const nuraft::raft_params &raft_params) -> bool
Initializes the NuRaft instance with the given state machine and raft parameters.
auto last_log_idx() const -> uint64_t
Returns the last replicated log index.
auto operator=(const node &) -> node &=delete
auto replicate_sync(const nuraft::ptr< nuraft::buffer > &new_log) const -> std::optional< nuraft::ptr< nuraft::buffer > >
Replicates the provided log entry and returns the results from the state machine if the replication w...
node(const node &)=delete
auto is_leader() const -> bool
Indicates whether this node is the current raft leader.
Implementation of nuraft::state_mgr using a file.
Tools for reading options from a configuration file and building application-specific parameter sets ...
nuraft::cmd_result< nuraft::ptr< nuraft::buffer > > result_type
A NuRaft state machine execution result.
std::function< void(result_type &r, nuraft::ptr< std::exception > &err)> callback_type
Function type for raft state machine execution result callbacks.