raft 0.1.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
raft::enhanced::Server Class Reference

#include <server.hpp>

Public Member Functions

 Server (ServerCreateConfig config)
 
 Server (Server const &)=delete
 
Serveroperator= (Server const &)=delete
 
 Server (Server &&) noexcept
 
Serveroperator= (Server &&) noexcept
 
void commit (RequestInfo const &info, const std::vector< std::byte > &value, LocalCommitCallback callback)
 
void endSession (std::string const &clientID, EndSessionCallback callback)
 
void setCommitCallback (GlobalCommitCallback callback)
 
void clearCommitCallback ()
 

Detailed Description

Enhanced Raft server providing high-level functionality on top of the core Raft implementation.

This wrapper provides commit management, deduplication, and simplified callback management. All functions are thread-safe. Callbacks are queued and executed in a serialized fashion, so it is important to keep callbacks lightweight. Since this class maintains a separate queue, it may be inconsistent with the underlying server instance.

For deduplication, the first commit for a clientID implicitly begins a session. Subsequent commit calls operate within this session until endSession() terminates it and cleans up deduplication information.

Member Function Documentation

◆ commit()

void raft::enhanced::Server::commit ( RequestInfo const &  info,
const std::vector< std::byte > &  value,
LocalCommitCallback  callback 
)

Commits data to the Raft log and monitors leadership and timeouts.

Parameters
infoThe client and request ID for this request.
valueThe data to commit to the Raft log.
callbackThe callback to invoke when the commit is completed.

◆ endSession()

void raft::enhanced::Server::endSession ( std::string const &  clientID,
EndSessionCallback  callback 
)

Ends the session for a specific client. The current server must be the leader for this to succeed.

Parameters
clientIDThe client ID to clear from deduplication tracking.

The documentation for this class was generated from the following file: