pub trait Responder<C>: OptionalSend + 'staticwhere
C: RaftTypeConfig,{
type Receiver;
// Required methods
fn from_app_data(app_data: C::D) -> (C::D, Self, Self::Receiver)
where Self: Sized;
fn send(self, result: ClientWriteResult<C>);
}
Expand description
A trait that lets RaftCore
send the response or an error of a client write request back to the
client or to somewhere else.
It is created for each request AppData
, and is sent to RaftCore
.
Once the request is completed,
the RaftCore
send the result ClientWriteResult
via it.
The implementation of the trait then forward the response to application.
There could optionally be a receiver to wait for the response.
Usually an implementation of Responder
is a oneshot channel Sender,
and Responder::Receiver
is a oneshot channel Receiver.
Required Associated Types§
Required Methods§
sourcefn from_app_data(app_data: C::D) -> (C::D, Self, Self::Receiver)where
Self: Sized,
fn from_app_data(app_data: C::D) -> (C::D, Self, Self::Receiver)where
Self: Sized,
Build a new instance from the application request.
sourcefn send(self, result: ClientWriteResult<C>)
fn send(self, result: ClientWriteResult<C>)
Send result when the request has been completed.
This method is called by the RaftCore
once the request has been applied to state machine.