mirror of
https://git.asonix.dog/asonix/background-jobs.git
synced 2024-11-21 19:40:59 +00:00
Update example
This commit is contained in:
parent
3eda504199
commit
f92ae865a3
1 changed files with 6 additions and 2 deletions
|
@ -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(())),
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue