raft 0.1.0
|
#include <typed_server.hpp>
Public Member Functions | |
Server (ServerCreateConfig config) | |
Server (Server const &)=delete | |
Server & | operator= (Server const &)=delete |
Server (Server &&)=default | |
Server & | operator= (Server &&)=default |
void | commit (RequestInfo const &info, const T &value, LocalCommitCallback< T, E > callback) |
void | endSession (std::string const &clientID, std::function< void(tl::expected< void, Error >)> callback) |
void | setCommitCallback (GlobalCommitCallback< T, E > callback) |
void | clearCommitCallback () |
Clears the global commit callback. | |
Type-safe wrapper around enhanced Raft server providing automatic serialization.
This wrapper provides the same functionality as raft::enhanced::Server but with type safety and automatic serialization/deserialization. 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.
T | The data type to be committed to the Raft log. |
E | The error type for deserialization failures. |
|
inlineexplicit |
Constructs a typed enhanced server.
config | Configuration for creating the underlying enhanced server. |
|
inline |
Commits typed data to the Raft log and monitors leadership and timeouts.
The data is automatically serialized before being committed to the underlying Raft server. The callback receives either the deserialized committed data or an error (either from Raft operations or deserialization failures).
info | The client and request ID for this request (used for deduplication). |
value | The typed data to commit to the Raft log. |
callback | The callback to invoke when the commit is completed. |
|
inline |
Ends the session for a specific client.
clientID | The client ID to clear from deduplication tracking. |
callback | The callback to invoke when the session is ended. |
|
inline |
Sets a global commit callback for all committed entries.
The callback receives automatically deserialized data for all entries committed to the Raft log (both local commits through commit() and remote commits from other servers).
callback | The callback to invoke for all committed entries. |