pub struct RaftServiceImpl { /* private fields */ }Expand description
Internal gRPC service implementation for Raft protocol communications. This service handles the core Raft consensus protocol operations between cluster nodes.
§Responsibilities
- Vote requests/responses during leader election
- Log replication between nodes
- Snapshot installation for state synchronization
§Protocol Safety
This service implements critical consensus protocol operations and should only be exposed to other trusted Raft cluster nodes, never to external clients.
Implementations§
Source§impl RaftServiceImpl
impl RaftServiceImpl
Sourcepub fn new(raft_node: Raft<TypeConfig>) -> Self
pub fn new(raft_node: Raft<TypeConfig>) -> Self
Creates a new instance of the internal service
§Arguments
raft_node- The Raft node instance this service will operate on
Trait Implementations§
Source§impl RaftService for RaftServiceImpl
impl RaftService for RaftServiceImpl
Source§fn vote<'life0, 'async_trait>(
&'life0 self,
request: Request<VoteRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<VoteResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn vote<'life0, 'async_trait>(
&'life0 self,
request: Request<VoteRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<VoteResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handles vote requests during leader election.
§Arguments
request- The vote request containing candidate information
§Returns
Ok(Response)- Vote response indicating whether the vote was grantedErr(Status)- Error status if the vote operation fails
§Protocol Details
This implements the RequestVote RPC from the Raft protocol. Nodes vote for candidates based on log completeness and term numbers.
Source§fn append_entries<'life0, 'async_trait>(
&'life0 self,
request: Request<AppendEntriesRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<AppendEntriesResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn append_entries<'life0, 'async_trait>(
&'life0 self,
request: Request<AppendEntriesRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<AppendEntriesResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handles append entries requests for log replication.
§Arguments
request- The append entries request containing log entries to replicate
§Returns
Ok(Response)- Response indicating success/failure of the append operationErr(Status)- Error status if the append operation fails
§Protocol Details
This implements the AppendEntries RPC from the Raft protocol. Used for both log replication and as heartbeat mechanism.
Source§fn snapshot<'life0, 'async_trait>(
&'life0 self,
request: Request<Streaming<SnapshotRequest>>,
) -> Pin<Box<dyn Future<Output = Result<Response<SnapshotResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn snapshot<'life0, 'async_trait>(
&'life0 self,
request: Request<Streaming<SnapshotRequest>>,
) -> Pin<Box<dyn Future<Output = Result<Response<SnapshotResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn stream_append<'life0, 'async_trait>(
&'life0 self,
request: Request<Streaming<AppendEntriesRequest>>,
) -> Pin<Box<dyn Future<Output = Result<Response<Self::StreamAppendStream>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stream_append<'life0, 'async_trait>(
&'life0 self,
request: Request<Streaming<AppendEntriesRequest>>,
) -> Pin<Box<dyn Future<Output = Result<Response<Self::StreamAppendStream>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handles streaming append entries requests for pipeline replication.
This enables efficient pipelining of log replication where multiple AppendEntries requests can be in-flight simultaneously.
Source§type StreamAppendStream = Pin<Box<dyn Stream<Item = Result<AppendEntriesResponse, Status>> + Send>>
type StreamAppendStream = Pin<Box<dyn Stream<Item = Result<AppendEntriesResponse, Status>> + Send>>
Auto Trait Implementations§
impl Freeze for RaftServiceImpl
impl RefUnwindSafe for RaftServiceImpl
impl Send for RaftServiceImpl
impl Sync for RaftServiceImpl
impl Unpin for RaftServiceImpl
impl UnsafeUnpin for RaftServiceImpl
impl UnwindSafe for RaftServiceImpl
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> 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