@@ -66,18 +66,18 @@ impl GrpcClient {
66
66
67
67
/// Returns whether this gRPC status means the server stream should be reconnected to, or not.
68
68
/// Logs a warning on unexpected status codes.
69
- fn is_retryable ( status : & Status ) -> bool {
69
+ fn is_retryable ( status : & Status , address : & str ) -> bool {
70
70
match status. code ( ) {
71
71
Code :: DeadlineExceeded | Code :: Aborted | Code :: Unavailable | Code :: Unknown => {
72
- info ! ( "gRPC request interrupted: {}; retrying" , status ) ;
72
+ info ! ( "gRPC request to {address} interrupted: {status }; retrying" ) ;
73
73
true
74
74
}
75
75
Code :: Ok
76
76
| Code :: Cancelled
77
77
| Code :: NotFound
78
78
| Code :: AlreadyExists
79
79
| Code :: ResourceExhausted => {
80
- error ! ( "Unexpected gRPC status : {}; retrying" , status ) ;
80
+ error ! ( "gRPC request to {address} interrupted : {status }; retrying" ) ;
81
81
true
82
82
}
83
83
Code :: InvalidArgument
@@ -88,7 +88,7 @@ impl GrpcClient {
88
88
| Code :: Internal
89
89
| Code :: DataLoss
90
90
| Code :: Unauthenticated => {
91
- error ! ( "Unexpected gRPC status: {}" , status) ;
91
+ error ! ( "Unexpected gRPC status received from {address}: { status}" ) ;
92
92
false
93
93
}
94
94
}
@@ -99,6 +99,7 @@ impl GrpcClient {
99
99
f : F ,
100
100
request : impl TryInto < R > + fmt:: Debug + Clone ,
101
101
handler : & str ,
102
+ address : & str ,
102
103
) -> Result < S , NodeError >
103
104
where
104
105
F : Fn ( ValidatorNodeClient < transport:: Channel > , Request < R > ) -> Fut ,
@@ -112,15 +113,17 @@ impl GrpcClient {
112
113
} ) ?;
113
114
loop {
114
115
match f ( self . client . clone ( ) , Request :: new ( request_inner. clone ( ) ) ) . await {
115
- Err ( s) if Self :: is_retryable ( & s) && retry_count < self . max_retries => {
116
+ Err ( s) if Self :: is_retryable ( & s, address ) && retry_count < self . max_retries => {
116
117
let delay = self . retry_delay . saturating_mul ( retry_count) ;
117
118
retry_count += 1 ;
118
119
tokio:: time:: sleep ( delay) . await ;
119
120
continue ;
120
121
}
121
122
Err ( s) => {
122
123
return Err ( NodeError :: GrpcError {
123
- error : format ! ( "remote request [{handler}] failed with status: {s:?}" , ) ,
124
+ error : format ! (
125
+ "remote request [{handler}] to {address} failed with status: {s:?}" ,
126
+ ) ,
124
127
} ) ;
125
128
}
126
129
Ok ( result) => return Ok ( result. into_inner ( ) ) ,
@@ -159,6 +162,7 @@ macro_rules! client_delegate {
159
162
|mut client, req| async move { client. $handler( req) . await } ,
160
163
$req,
161
164
stringify!( $handler) ,
165
+ & $self. address,
162
166
)
163
167
. await
164
168
} } ;
@@ -256,6 +260,7 @@ impl ValidatorNode for GrpcClient {
256
260
257
261
// The stream of `Notification`s that inserts increasing delays after retriable errors, and
258
262
// terminates after unexpected or fatal errors.
263
+ let address = self . address . clone ( ) ;
259
264
let notification_stream = endlessly_retrying_notification_stream
260
265
. map ( |result| {
261
266
Option :: < Notification > :: try_from ( result?) . map_err ( |err| {
@@ -268,7 +273,7 @@ impl ValidatorNode for GrpcClient {
268
273
retry_count = 0 ;
269
274
return future:: Either :: Left ( future:: ready ( true ) ) ;
270
275
} ;
271
- if !Self :: is_retryable ( status) || retry_count >= max_retries {
276
+ if !Self :: is_retryable ( status, & address ) || retry_count >= max_retries {
272
277
return future:: Either :: Left ( future:: ready ( false ) ) ;
273
278
}
274
279
let delay = retry_delay. saturating_mul ( retry_count) ;
0 commit comments