1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use anyhow::Result;
use async_trait::async_trait;
use crate::raft::{AppendEntriesRequest, AppendEntriesResponse};
use crate::raft::{InstallSnapshotRequest, InstallSnapshotResponse};
use crate::raft::{VoteRequest, VoteResponse};
use crate::{AppData, NodeId};
#[async_trait]
pub trait RaftNetwork<D>: Send + Sync + 'static
where
D: AppData,
{
async fn append_entries(
&self,
target: NodeId,
rpc: AppendEntriesRequest<D>,
) -> Result<AppendEntriesResponse>;
async fn install_snapshot(
&self,
target: NodeId,
rpc: InstallSnapshotRequest,
) -> Result<InstallSnapshotResponse>;
async fn vote(&self, target: NodeId, rpc: VoteRequest) -> Result<VoteResponse>;
}