10#include <tl/expected.hpp>
12#include "raft/errors.hpp"
17 constexpr uint64_t DEFAULT_TIMEOUT_MS = 1000;
24 bool operator==(
NoOp const& other)
const =
default;
33 bool operator==(
LogEntry const& other)
const =
default;
102 std::function<
void(tl::expected<data::AppendEntriesResponse, Error>)> callback) = 0;
111 std::function<
void(tl::expected<data::RequestVoteResponse, Error>)> callback) = 0;
118 tl::expected<std::unique_ptr<Client>, Error> createClient(std::string
const& address);
132 std::string
const& address) = 0;
137 std::shared_ptr<ClientFactory> createClientFactory();
Definition client.hpp:124
virtual tl::expected< std::unique_ptr< Client >, Error > createClient(std::string const &address)=0
virtual void requestVote(data::RequestVoteRequest request, RequestConfig config, std::function< void(tl::expected< data::RequestVoteResponse, Error >)> callback)=0
virtual void appendEntries(data::AppendEntriesRequest request, RequestConfig config, std::function< void(tl::expected< data::AppendEntriesResponse, Error >)> callback)=0
RequestConfig defines the configuration for a request.
Definition client.hpp:84
uint64_t timeout
The timeout in milliseconds for the request.
Definition client.hpp:85
The request message for AppendEntries.
Definition client.hpp:38
uint64_t prevLogTerm
The term of the log entry at prev_log_index.
Definition client.hpp:43
uint64_t term
The current term.
Definition client.hpp:39
uint64_t leaderCommit
The leader's commit index.
Definition client.hpp:46
std::string leaderID
The leader's ID.
Definition client.hpp:40
uint64_t prevLogIndex
The index of the log entry immediately preceding the new ones.
Definition client.hpp:42
std::vector< LogEntry > entries
The log entries to store. This may be empty for a heartbeat.
Definition client.hpp:45
The reply message for AppendEntries.
Definition client.hpp:53
uint64_t term
The current term.
Definition client.hpp:54
bool success
Definition client.hpp:55
LogEntry represents a single log entry in the Raft log.
Definition client.hpp:29
uint64_t term
The term of the log entry.
Definition client.hpp:30
std::variant< std::vector< std::byte >, NoOp > entry
The entry data or no-op.
Definition client.hpp:31
NoOp is an empty struct that denotes a no-op log entry.
Definition client.hpp:23
The request message for RequestVote.
Definition client.hpp:63
uint64_t lastLogTerm
The term of the candidate's last log entry.
Definition client.hpp:67
uint64_t lastLogIndex
The index of the candidate's last log entry.
Definition client.hpp:66
uint64_t term
The current term.
Definition client.hpp:64
std::string candidateID
The candidate's ID.
Definition client.hpp:65
The reply message for RequestVote.
Definition client.hpp:74
bool voteGranted
True if the candidate received a vote.
Definition client.hpp:76
uint64_t term
The current term.
Definition client.hpp:75