mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 06:16:04 +00:00
rename add_with_exponential_backoff to add_and_retry_forever
This commit is contained in:
parent
45f9d27601
commit
175eacfac3
2 changed files with 6 additions and 10 deletions
|
@ -376,9 +376,7 @@ async fn swarm_handle(
|
|||
SwarmEvent::Disconnect(account) => {
|
||||
println!("bot got kicked! {}", account.username);
|
||||
tokio::time::sleep(Duration::from_secs(5)).await;
|
||||
swarm
|
||||
.add_with_exponential_backoff(account, State::default())
|
||||
.await;
|
||||
swarm.add_and_retry_forever(account, State::default()).await;
|
||||
}
|
||||
SwarmEvent::Chat(m) => {
|
||||
println!("swarm chat message: {}", m.message().to_ansi());
|
||||
|
|
|
@ -349,9 +349,7 @@ where
|
|||
if let Some(join_delay) = join_delay {
|
||||
// if there's a join delay, then join one by one
|
||||
for (account, state) in accounts.iter().zip(states) {
|
||||
swarm_clone
|
||||
.add_with_exponential_backoff(account, state)
|
||||
.await;
|
||||
swarm_clone.add_and_retry_forever(account, state).await;
|
||||
tokio::time::sleep(join_delay).await;
|
||||
}
|
||||
} else {
|
||||
|
@ -364,7 +362,7 @@ where
|
|||
.map(move |(account, state)| async {
|
||||
swarm_borrow
|
||||
.clone()
|
||||
.add_with_exponential_backoff(account, state)
|
||||
.add_and_retry_forever(account, state)
|
||||
.await;
|
||||
}),
|
||||
)
|
||||
|
@ -575,9 +573,9 @@ impl Swarm {
|
|||
/// Add a new account to the swarm, retrying if it couldn't join. This will
|
||||
/// run forever until the bot joins or the task is aborted.
|
||||
///
|
||||
/// Exponential backoff means if it fails joining it will initially wait 10
|
||||
/// seconds, then 20, then 40, up to 2 minutes.
|
||||
pub async fn add_with_exponential_backoff<S: Component + Clone>(
|
||||
/// This does exponential backoff (though very limited), starting at 5
|
||||
/// seconds and doubling up to 15 seconds.
|
||||
pub async fn add_and_retry_forever<S: Component + Clone>(
|
||||
&mut self,
|
||||
account: &Account,
|
||||
state: S,
|
||||
|
|
Loading…
Add table
Reference in a new issue