raft 0.1.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
raft::enhanced::typed::Server< T, E > Class Template Reference

#include <typed_server.hpp>

Public Member Functions

 Server (ServerCreateConfig config)
 
 Server (Server const &)=delete
 
Serveroperator= (Server const &)=delete
 
 Server (Server &&)=default
 
Serveroperator= (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.
 

Detailed Description

template<typename T, typename E>
requires Serializable<T, E>
class raft::enhanced::typed::Server< T, E >

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.

Template Parameters
TThe data type to be committed to the Raft log.
EThe error type for deserialization failures.

Constructor & Destructor Documentation

◆ Server()

template<typename T , typename E >
raft::enhanced::typed::Server< T, E >::Server ( ServerCreateConfig  config)
inlineexplicit

Constructs a typed enhanced server.

Parameters
configConfiguration for creating the underlying enhanced server.

Member Function Documentation

◆ commit()

template<typename T , typename E >
void raft::enhanced::typed::Server< T, E >::commit ( RequestInfo const &  info,
const T &  value,
LocalCommitCallback< T, E >  callback 
)
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).

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

◆ endSession()

template<typename T , typename E >
void raft::enhanced::typed::Server< T, E >::endSession ( std::string const &  clientID,
std::function< void(tl::expected< void, Error >)>  callback 
)
inline

Ends the session for a specific client.

Parameters
clientIDThe client ID to clear from deduplication tracking.
callbackThe callback to invoke when the session is ended.

◆ setCommitCallback()

template<typename T , typename E >
void raft::enhanced::typed::Server< T, E >::setCommitCallback ( GlobalCommitCallback< T, E >  callback)
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).

Parameters
callbackThe callback to invoke for all committed entries.

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