@@ -31,18 +31,6 @@ use crate::Vote;
31
31
///
32
32
/// A single network instance is used to connect to a single target node. The network instance is
33
33
/// constructed by the [`RaftNetworkFactory`](`crate::network::RaftNetworkFactory`).
34
- ///
35
- /// ### 2023-05-03: New API with options
36
- ///
37
- /// - This trait introduced 3 new API `append_entries`, `install_snapshot` and `vote` which accept
38
- /// an additional argument [`RPCOption`], and deprecated the old API `send_append_entries`,
39
- /// `send_install_snapshot` and `send_vote`.
40
- ///
41
- /// - The old API will be **removed** in `0.9`. An application can still implement the old API
42
- /// without any changes. Openraft calls only the new API and the default implementation will
43
- /// delegate to the old API.
44
- ///
45
- /// - Implementing the new APIs will disable the old APIs.
46
34
#[ add_async_trait]
47
35
pub trait RaftNetwork < C > : OptionalSend + OptionalSync + ' static
48
36
where C : RaftTypeConfig
@@ -52,37 +40,26 @@ where C: RaftTypeConfig
52
40
& mut self ,
53
41
rpc : AppendEntriesRequest < C > ,
54
42
option : RPCOption ,
55
- ) -> Result < AppendEntriesResponse < C :: NodeId > , RPCError < C :: NodeId , C :: Node , RaftError < C :: NodeId > > > {
56
- let _ = option;
57
- #[ allow( deprecated) ]
58
- self . send_append_entries ( rpc) . await
59
- }
43
+ ) -> Result < AppendEntriesResponse < C :: NodeId > , RPCError < C :: NodeId , C :: Node , RaftError < C :: NodeId > > > ;
60
44
61
45
/// Send an InstallSnapshot RPC to the target.
46
+ #[ cfg( not( feature = "generic-snapshot-data" ) ) ]
62
47
#[ deprecated( since = "0.9.0" , note = "use `snapshot()` instead for sending a complete snapshot" ) ]
63
48
async fn install_snapshot (
64
49
& mut self ,
65
- rpc : InstallSnapshotRequest < C > ,
66
- option : RPCOption ,
50
+ _rpc : InstallSnapshotRequest < C > ,
51
+ _option : RPCOption ,
67
52
) -> Result <
68
53
InstallSnapshotResponse < C :: NodeId > ,
69
54
RPCError < C :: NodeId , C :: Node , RaftError < C :: NodeId , InstallSnapshotError > > ,
70
- > {
71
- let _ = option;
72
- #[ allow( deprecated) ]
73
- self . send_install_snapshot ( rpc) . await
74
- }
55
+ > ;
75
56
76
57
/// Send a RequestVote RPC to the target.
77
58
async fn vote (
78
59
& mut self ,
79
60
rpc : VoteRequest < C :: NodeId > ,
80
61
option : RPCOption ,
81
- ) -> Result < VoteResponse < C :: NodeId > , RPCError < C :: NodeId , C :: Node , RaftError < C :: NodeId > > > {
82
- let _ = option;
83
- #[ allow( deprecated) ]
84
- self . send_vote ( rpc) . await
85
- }
62
+ ) -> Result < VoteResponse < C :: NodeId > , RPCError < C :: NodeId , C :: Node , RaftError < C :: NodeId > > > ;
86
63
87
64
/// Send a complete Snapshot to the target.
88
65
///
@@ -99,67 +76,28 @@ where C: RaftTypeConfig
99
76
/// with this vote.
100
77
///
101
78
/// `cancel` get `Ready` when the caller decides to cancel this snapshot transmission.
79
+ #[ cfg( feature = "generic-snapshot-data" ) ]
102
80
async fn snapshot (
103
81
& mut self ,
104
82
vote : Vote < C :: NodeId > ,
105
83
snapshot : Snapshot < C > ,
106
84
cancel : impl Future < Output = ReplicationClosed > + OptionalSend ,
107
85
option : RPCOption ,
108
- ) -> Result < SnapshotResponse < C :: NodeId > , StreamingError < C , Fatal < C :: NodeId > > > {
109
- #[ cfg( not( feature = "generic-snapshot-data" ) ) ]
110
- {
111
- use crate :: network:: stream_snapshot;
112
- use crate :: network:: stream_snapshot:: SnapshotTransport ;
113
-
114
- let resp = stream_snapshot:: Chunked :: send_snapshot ( self , vote, snapshot, cancel, option) . await ?;
115
- Ok ( resp)
116
- }
117
- #[ cfg( feature = "generic-snapshot-data" ) ]
118
- {
119
- let _ = ( vote, snapshot, cancel, option) ;
120
- unimplemented ! (
121
- "no default implementation for RaftNetwork::snapshot() if `generic-snapshot-data` feature is enabled"
122
- )
123
- }
124
- }
86
+ ) -> Result < SnapshotResponse < C :: NodeId > , StreamingError < C , Fatal < C :: NodeId > > > ;
125
87
126
- /// Send an AppendEntries RPC to the target Raft node (§5).
127
- #[ deprecated(
128
- since = "0.8.4" ,
129
- note = "use `append_entries` instead. This method will be removed in 0.9"
130
- ) ]
131
- async fn send_append_entries (
132
- & mut self ,
133
- rpc : AppendEntriesRequest < C > ,
134
- ) -> Result < AppendEntriesResponse < C :: NodeId > , RPCError < C :: NodeId , C :: Node , RaftError < C :: NodeId > > > {
135
- let _ = rpc;
136
- unimplemented ! ( "send_append_entries is deprecated" )
137
- }
138
-
139
- /// Send an InstallSnapshot RPC to the target Raft node (§7).
140
- #[ deprecated(
141
- since = "0.8.4" ,
142
- note = "use `install_snapshot` instead. This method will be removed in 0.9"
143
- ) ]
144
- async fn send_install_snapshot (
88
+ #[ cfg( not( feature = "generic-snapshot-data" ) ) ]
89
+ async fn snapshot (
145
90
& mut self ,
146
- rpc : InstallSnapshotRequest < C > ,
147
- ) -> Result <
148
- InstallSnapshotResponse < C :: NodeId > ,
149
- RPCError < C :: NodeId , C :: Node , RaftError < C :: NodeId , InstallSnapshotError > > ,
150
- > {
151
- let _ = rpc;
152
- unimplemented ! ( "send_install_snapshot is deprecated" )
153
- }
91
+ vote : Vote < C :: NodeId > ,
92
+ snapshot : Snapshot < C > ,
93
+ cancel : impl Future < Output = ReplicationClosed > + OptionalSend ,
94
+ option : RPCOption ,
95
+ ) -> Result < SnapshotResponse < C :: NodeId > , StreamingError < C , Fatal < C :: NodeId > > > {
96
+ use crate :: network:: stream_snapshot;
97
+ use crate :: network:: stream_snapshot:: SnapshotTransport ;
154
98
155
- /// Send a RequestVote RPC to the target Raft node (§5).
156
- #[ deprecated( since = "0.8.4" , note = "use `vote` instead. This method will be removed in 0.9" ) ]
157
- async fn send_vote (
158
- & mut self ,
159
- rpc : VoteRequest < C :: NodeId > ,
160
- ) -> Result < VoteResponse < C :: NodeId > , RPCError < C :: NodeId , C :: Node , RaftError < C :: NodeId > > > {
161
- let _ = rpc;
162
- unimplemented ! ( "send_vote is deprecated" )
99
+ let resp = stream_snapshot:: Chunked :: send_snapshot ( self , vote, snapshot, cancel, option) . await ?;
100
+ Ok ( resp)
163
101
}
164
102
165
103
/// Build a backoff instance if the target node is temporarily(or permanently) unreachable.
0 commit comments