File tree 2 files changed +9
-2
lines changed
raft-kv-memstore/src/network
2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ impl Network {
43
43
tracing:: debug!( "client is created for: {}" , url) ;
44
44
45
45
let resp = client. post ( url) . json ( & req) . send ( ) . await . map_err ( |e| {
46
- // If the error is a connection error, we return Unreachable so that connection isn't retried
46
+ // If the error is a connection error, we return ` Unreachable` so that connection isn't retried
47
47
// immediately.
48
48
if e. is_connect ( ) {
49
49
return openraft:: error:: RPCError :: Unreachable ( Unreachable :: new ( & e) ) ;
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ use std::sync::Mutex;
5
5
use openraft:: error:: NetworkError ;
6
6
use openraft:: error:: RPCError ;
7
7
use openraft:: error:: RemoteError ;
8
+ use openraft:: error:: Unreachable ;
8
9
use openraft:: RaftMetrics ;
9
10
use openraft:: TryAsRef ;
10
11
use reqwest:: Client ;
@@ -142,7 +143,13 @@ impl ExampleClient {
142
143
}
143
144
. send ( )
144
145
. await
145
- . map_err ( |e| RPCError :: Network ( NetworkError :: new ( & e) ) ) ?;
146
+ . map_err ( |e| {
147
+ if e. is_connect ( ) {
148
+ // `Unreachable` informs the caller to backoff for a short while to avoid error log flush.
149
+ return RPCError :: Unreachable ( Unreachable :: new ( & e) ) ;
150
+ }
151
+ RPCError :: Network ( NetworkError :: new ( & e) )
152
+ } ) ?;
146
153
147
154
let res: Result < Resp , Err > = resp. json ( ) . await . map_err ( |e| RPCError :: Network ( NetworkError :: new ( & e) ) ) ?;
148
155
println ! (
You can’t perform that action at this time.
0 commit comments