Skip to content

Commit 175eacf

Browse files
committed
rename add_with_exponential_backoff to add_and_retry_forever
1 parent 45f9d27 commit 175eacf

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

azalea/examples/testbot.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,7 @@ async fn swarm_handle(
376376
SwarmEvent::Disconnect(account) => {
377377
println!("bot got kicked! {}", account.username);
378378
tokio::time::sleep(Duration::from_secs(5)).await;
379-
swarm
380-
.add_with_exponential_backoff(account, State::default())
381-
.await;
379+
swarm.add_and_retry_forever(account, State::default()).await;
382380
}
383381
SwarmEvent::Chat(m) => {
384382
println!("swarm chat message: {}", m.message().to_ansi());

azalea/src/swarm/mod.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,7 @@ where
349349
if let Some(join_delay) = join_delay {
350350
// if there's a join delay, then join one by one
351351
for (account, state) in accounts.iter().zip(states) {
352-
swarm_clone
353-
.add_with_exponential_backoff(account, state)
354-
.await;
352+
swarm_clone.add_and_retry_forever(account, state).await;
355353
tokio::time::sleep(join_delay).await;
356354
}
357355
} else {
@@ -364,7 +362,7 @@ where
364362
.map(move |(account, state)| async {
365363
swarm_borrow
366364
.clone()
367-
.add_with_exponential_backoff(account, state)
365+
.add_and_retry_forever(account, state)
368366
.await;
369367
}),
370368
)
@@ -575,9 +573,9 @@ impl Swarm {
575573
/// Add a new account to the swarm, retrying if it couldn't join. This will
576574
/// run forever until the bot joins or the task is aborted.
577575
///
578-
/// Exponential backoff means if it fails joining it will initially wait 10
579-
/// seconds, then 20, then 40, up to 2 minutes.
580-
pub async fn add_with_exponential_backoff<S: Component + Clone>(
576+
/// This does exponential backoff (though very limited), starting at 5
577+
/// seconds and doubling up to 15 seconds.
578+
pub async fn add_and_retry_forever<S: Component + Clone>(
581579
&mut self,
582580
account: &Account,
583581
state: S,

0 commit comments

Comments
 (0)