Trait openraft::raft::responder::Responder

source ·
pub trait Responder<C>: OptionalSend + 'static
where 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§

source

type Receiver

An optional receiver to receive the result sent by RaftCore.

If the application does not need to wait for the response, it can be ().

Required Methods§

source

fn from_app_data(app_data: C::D) -> (C::D, Self, Self::Receiver)
where Self: Sized,

Build a new instance from the application request.

source

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.

Implementors§