From 18f62fc4fddb5f01120f2f5087a42fad325133b4 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Wed, 19 Jan 2022 09:00:28 -0500 Subject: [PATCH] refactor: Rename function to retry_with_backoff --- src/backoff.rs | 2 +- src/client/controller.rs | 2 +- src/client/partition.rs | 2 +- src/connection.rs | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/backoff.rs b/src/backoff.rs index afec84f2..8fd85a3f 100644 --- a/src/backoff.rs +++ b/src/backoff.rs @@ -83,7 +83,7 @@ impl Backoff { } /// Perform an async operation that retries with a backoff - pub async fn backy_offy(&mut self, request_name: &str, do_stuff: F) -> B + pub async fn retry_with_backoff(&mut self, request_name: &str, do_stuff: F) -> B where F: (Fn() -> F1) + Send + Sync, F1: std::future::Future> + Send, diff --git a/src/client/controller.rs b/src/client/controller.rs index c1ef4303..7daf66a2 100644 --- a/src/client/controller.rs +++ b/src/client/controller.rs @@ -90,7 +90,7 @@ impl ControllerClient { let mut backoff = Backoff::new(&self.backoff_config); backoff - .backy_offy(request_name, || async { + .retry_with_backoff(request_name, || async { let error = match f().await { Ok(v) => return ControlFlow::Break(Ok(v)), Err(e) => e, diff --git a/src/client/partition.rs b/src/client/partition.rs index 16b612f7..e98cfd89 100644 --- a/src/client/partition.rs +++ b/src/client/partition.rs @@ -381,7 +381,7 @@ impl PartitionClient { let mut backoff = Backoff::new(&self.backoff_config); backoff - .backy_offy(request_name, || async { + .retry_with_backoff(request_name, || async { let error = match f().await { Ok(v) => return ControlFlow::Break(Ok(v)), Err(e) => e, diff --git a/src/connection.rs b/src/connection.rs index 55c689f4..67608e71 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -210,7 +210,7 @@ impl ArbitraryBrokerCache for &BrokerConnector { let mut backoff = Backoff::new(&self.backoff_config); let connection = backoff - .backy_offy("broker_connect", || async { + .retry_with_backoff("broker_connect", || async { for broker in &brokers { let connection = match self.connect_impl(None, broker).await { Ok(transport) => transport, @@ -246,7 +246,7 @@ where A: ArbitraryBrokerCache, { backoff - .backy_offy("metadata", || async { + .retry_with_backoff("metadata", || async { // Retrieve the broker within the loop, in case it is invalidated let broker = match broker_override.as_ref() { Some(b) => Arc::clone(b),