Update example

This commit is contained in:
asonix 2018-11-06 21:37:14 -06:00
parent 3eda504199
commit f92ae865a3

View file

@ -6,7 +6,7 @@ use futures::{
future::{lazy, IntoFuture}, future::{lazy, IntoFuture},
Future, Future,
}; };
use jobs::{JobRunner, MaxRetries, Processor}; use jobs::{Backoff, JobRunner, MaxRetries, Processor};
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
struct MyJobArguments { struct MyJobArguments {
@ -27,6 +27,10 @@ impl Processor for MyProcessor {
MaxRetries::Count(1) MaxRetries::Count(1)
} }
fn backoff_strategy() -> Backoff {
Backoff::Exponential(2)
}
fn process(&self, args: Self::Arguments) -> Box<dyn Future<Item = (), Error = Error> + Send> { fn process(&self, args: Self::Arguments) -> Box<dyn Future<Item = (), Error = Error> + Send> {
println!("args: {:?}", args); println!("args: {:?}", args);
@ -68,7 +72,7 @@ fn main() {
.map(|job| { .map(|job| {
tokio::spawn( tokio::spawn(
handle handle
.queue(MyProcessor::new_job(job, None).unwrap()) .queue(MyProcessor::new_job(job, None, None).unwrap())
.then(|_| Ok(())), .then(|_| Ok(())),
); );
}) })