pub struct Mailbox { /* private fields */ }
Expand description
A mailbox to send messages to a running raft node.
Implementations§
Source§impl Mailbox
impl Mailbox
Sourcepub fn pears(&self) -> Vec<(u64, Peer)>
pub fn pears(&self) -> Vec<(u64, Peer)>
Retrieves a list of peers with their IDs.
This method returns a vector containing tuples of peer IDs and their respective Peer
objects.
It iterates over the internal peers
map and collects the IDs and cloned Peer
instances.
Sourcepub async fn send_proposal(&self, message: Vec<u8>) -> Result<Vec<u8>>
pub async fn send_proposal(&self, message: Vec<u8>) -> Result<Vec<u8>>
Sends a proposal to the leader node.
This method first attempts to send the proposal to the local node if it is the leader.
If the node is not the leader, it retrieves the leader’s address and sends the proposal to the leader node.
If the proposal is successfully handled, the method returns a RaftResponse::Response
with the resulting data.
Sourcepub async fn send(&self, message: Vec<u8>) -> Result<Vec<u8>>
👎Deprecated
pub async fn send(&self, message: Vec<u8>) -> Result<Vec<u8>>
Deprecated method to send a message, internally calls send_proposal
.
Sourcepub async fn query(&self, query: Vec<u8>) -> Result<Vec<u8>>
pub async fn query(&self, query: Vec<u8>) -> Result<Vec<u8>>
Sends a query to the Raft node and returns the response data.
It sends a Message::Query
containing the query bytes and waits for a response.
On success, it returns the data wrapped in RaftResponse::Response
.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Mailbox
impl !RefUnwindSafe for Mailbox
impl Send for Mailbox
impl Sync for Mailbox
impl Unpin for Mailbox
impl !UnwindSafe for Mailbox
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request