Skip to content

Commit

Permalink
refactor: Rename function to retry_with_backoff
Browse files Browse the repository at this point in the history
  • Loading branch information
carols10cents committed Jan 19, 2022
1 parent 380a5e9 commit 18f62fc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/backoff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl Backoff {
}

/// Perform an async operation that retries with a backoff
pub async fn backy_offy<F, F1, B, C>(&mut self, request_name: &str, do_stuff: F) -> B
pub async fn retry_with_backoff<F, F1, B, C>(&mut self, request_name: &str, do_stuff: F) -> B
where
F: (Fn() -> F1) + Send + Sync,
F1: std::future::Future<Output = ControlFlow<B, C>> + Send,
Expand Down
2 changes: 1 addition & 1 deletion src/client/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/client/partition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 18f62fc

Please sign in to comment.