raft 0.1.0
|
#include <server.hpp>
Public Member Functions | |
Server (ServerCreateConfig config) | |
Server (Server const &)=delete | |
Server & | operator= (Server const &)=delete |
Server (Server &&) noexcept | |
Server & | operator= (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 () |
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.
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.
info | The client and request ID for this request. |
value | The data to commit to the Raft log. |
callback | The callback to invoke when the commit is completed. |
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.
clientID | The client ID to clear from deduplication tracking. |