mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-28 01:32:57 +01:00
Merge pull request #8 from Turbo87/backoff
Improve `ExponentialBackoff` handling
This commit is contained in:
commit
43396ab3e3
@ -37,10 +37,13 @@ impl RedisActor {
|
||||
pub fn start<S: Into<String>>(addr: S) -> Addr<Unsync, RedisActor> {
|
||||
let addr = addr.into();
|
||||
|
||||
let mut backoff = ExponentialBackoff::default();
|
||||
backoff.max_elapsed_time = None;
|
||||
|
||||
Supervisor::start(|_| RedisActor {
|
||||
addr: addr,
|
||||
cell: None,
|
||||
backoff: ExponentialBackoff::default(),
|
||||
backoff: backoff,
|
||||
queue: VecDeque::new(),
|
||||
})
|
||||
}
|
||||
@ -74,8 +77,6 @@ impl Actor for RedisActor {
|
||||
// we stop current context, supervisor will restart it.
|
||||
if let Some(timeout) = act.backoff.next_backoff() {
|
||||
ctx.run_later(timeout, |_, ctx| ctx.stop());
|
||||
} else {
|
||||
ctx.stop();
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -85,8 +86,6 @@ impl Actor for RedisActor {
|
||||
// we stop current context, supervisor will restart it.
|
||||
if let Some(timeout) = act.backoff.next_backoff() {
|
||||
ctx.run_later(timeout, |_, ctx| ctx.stop());
|
||||
} else {
|
||||
ctx.stop();
|
||||
}
|
||||
})
|
||||
.wait(ctx);
|
||||
|
Loading…
Reference in New Issue
Block a user