22
33use std:: time:: Duration ;
44
5- use backoff :: { ExponentialBackoff , Operation } ;
5+ use backon :: { BlockingRetryable , ExponentialBuilder } ;
66
77use rdkafka:: admin:: {
88 AdminClient , AdminOptions , AlterConfig , ConfigEntry , ConfigSource , GroupResult , NewPartitions ,
@@ -75,10 +75,6 @@ fn fetch_metadata(topic: &str) -> Metadata {
7575 create_config ( ) . create ( ) . expect ( "consumer creation failed" ) ;
7676 let timeout = Some ( Duration :: from_secs ( 1 ) ) ;
7777
78- let mut backoff = ExponentialBackoff {
79- max_elapsed_time : Some ( Duration :: from_secs ( 5 ) ) ,
80- ..Default :: default ( )
81- } ;
8278 ( || {
8379 let metadata = consumer
8480 . fetch_metadata ( Some ( topic) , timeout)
@@ -90,9 +86,10 @@ fn fetch_metadata(topic: &str) -> Metadata {
9086 if topic. partitions ( ) . is_empty ( ) {
9187 Err ( "metadata fetch returned a topic with no partitions" . to_string ( ) ) ?
9288 }
93- Ok ( metadata)
89+ Ok :: < _ , String > ( metadata)
9490 } )
95- . retry ( & mut backoff)
91+ . retry ( ExponentialBuilder :: default ( ) . with_max_delay ( Duration :: from_secs ( 5 ) ) )
92+ . call ( )
9693 . unwrap ( )
9794}
9895
@@ -101,10 +98,6 @@ fn verify_delete(topic: &str) {
10198 create_config ( ) . create ( ) . expect ( "consumer creation failed" ) ;
10299 let timeout = Some ( Duration :: from_secs ( 1 ) ) ;
103100
104- let mut backoff = ExponentialBackoff {
105- max_elapsed_time : Some ( Duration :: from_secs ( 5 ) ) ,
106- ..Default :: default ( )
107- } ;
108101 ( || {
109102 // Asking about the topic specifically will recreate it (under the
110103 // default Kafka configuration, at least) so we have to ask for the list
@@ -115,9 +108,10 @@ fn verify_delete(topic: &str) {
115108 if metadata. topics ( ) . iter ( ) . any ( |t| t. name ( ) == topic) {
116109 Err ( format ! ( "topic {} still exists" , topic) ) ?
117110 }
118- Ok ( ( ) )
111+ Ok :: < ( ) , String > ( ( ) )
119112 } )
120- . retry ( & mut backoff)
113+ . retry ( ExponentialBuilder :: default ( ) . with_max_delay ( Duration :: from_secs ( 5 ) ) )
114+ . call ( )
121115 . unwrap ( )
122116}
123117
0 commit comments