File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -470,6 +470,7 @@ where
470
470
let mut backoff = Backoff :: new ( backoff_config) ;
471
471
backoff
472
472
. retry_with_backoff ( "broker_connect" , || async {
473
+ let mut errors = Vec :: new ( ) ;
473
474
for broker in & brokers {
474
475
let conn = broker
475
476
. connect (
@@ -485,16 +486,24 @@ where
485
486
Ok ( transport) => transport,
486
487
Err ( e) => {
487
488
warn ! ( %e, "Failed to connect to broker" ) ;
489
+ errors. push ( e) ;
488
490
continue ;
489
491
}
490
492
} ;
491
493
492
494
return ControlFlow :: Break ( connection) ;
493
495
}
494
496
495
- let err = Box :: < dyn std:: error:: Error + Send + Sync > :: from (
496
- "Failed to connect to any broker, backing off" . to_string ( ) ,
497
- ) ;
497
+ // errors should always contain at least 1 element here.
498
+ let errors_string = errors
499
+ . into_iter ( )
500
+ . map ( |e| e. to_string ( ) )
501
+ . collect :: < Vec < String > > ( )
502
+ . join ( ", " ) ;
503
+
504
+ let err = Box :: < dyn std:: error:: Error + Send + Sync > :: from ( format ! (
505
+ "Failed to connect to any broker, backing off. Errors: {errors_string}"
506
+ ) ) ;
498
507
let err: Arc < dyn std:: error:: Error + Send + Sync > = err. into ( ) ;
499
508
ControlFlow :: Continue ( ErrorOrThrottle :: Error ( err) )
500
509
} )
Original file line number Diff line number Diff line change @@ -721,7 +721,11 @@ async fn test_client_backoff_terminates() {
721
721
722
722
match client_builder. build ( ) . await {
723
723
Err ( rskafka:: client:: error:: Error :: Connection ( e) ) => {
724
- assert_eq ! ( e. to_string( ) , "all retries failed: Retry exceeded deadline" ) ;
724
+ assert_eq ! ( e. to_string( ) , concat!(
725
+ "all retries failed: Retry exceeded deadline. " ,
726
+ "Source: Failed to connect to any broker, backing off. " ,
727
+ "Errors: error connecting to broker \" localhost:9000\" : IO Error: Connection refused (os error 111)"
728
+ ) ) ;
725
729
}
726
730
_ => {
727
731
unreachable ! ( ) ;
You can’t perform that action at this time.
0 commit comments