mirror of
https://git.asonix.dog/asonix/background-jobs.git
synced 2024-11-25 21:40:59 +00:00
Fix example
This commit is contained in:
parent
b40dc7dc93
commit
db12d38f15
1 changed files with 5 additions and 10 deletions
|
@ -22,26 +22,23 @@ use std::{future::Future, pin::Pin};
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use anyhow::Error;
|
/// use anyhow::Error;
|
||||||
/// use background_jobs_core::{Backoff, Job, MaxRetries, Processor};
|
/// use background_jobs_core::{Job, Processor};
|
||||||
/// use futures::future::{ok, Ready};
|
|
||||||
/// use log::info;
|
/// use log::info;
|
||||||
/// use serde_derive::{Deserialize, Serialize};
|
|
||||||
/// use std::future::Future;
|
|
||||||
///
|
///
|
||||||
/// #[derive(Deserialize, Serialize)]
|
/// #[derive(serde::Deserialize, serde::Serialize)]
|
||||||
/// struct MyJob {
|
/// struct MyJob {
|
||||||
/// count: i32,
|
/// count: i32,
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
|
/// #[async_trait::async_trait]
|
||||||
/// impl Job for MyJob {
|
/// impl Job for MyJob {
|
||||||
/// type Processor = MyProcessor;
|
/// type Processor = MyProcessor;
|
||||||
/// type State = ();
|
/// type State = ();
|
||||||
/// type Future = Ready<Result<(), Error>>;
|
|
||||||
///
|
///
|
||||||
/// fn run(self, _state: Self::State) -> Self::Future {
|
/// async fn run(self, _state: Self::State) -> Result<(), Error> {
|
||||||
/// info!("Processing {}", self.count);
|
/// info!("Processing {}", self.count);
|
||||||
///
|
///
|
||||||
/// ok(())
|
/// Ok(())
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
|
@ -53,8 +50,6 @@ use std::{future::Future, pin::Pin};
|
||||||
///
|
///
|
||||||
/// const NAME: &'static str = "IncrementProcessor";
|
/// const NAME: &'static str = "IncrementProcessor";
|
||||||
/// const QUEUE: &'static str = "default";
|
/// const QUEUE: &'static str = "default";
|
||||||
/// const MAX_RETRIES: MaxRetries = MaxRetries::Count(1);
|
|
||||||
/// const BACKOFF_STRATEGY: Backoff = Backoff::Exponential(2);
|
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// fn main() -> Result<(), Error> {
|
/// fn main() -> Result<(), Error> {
|
||||||
|
|
Loading…
Reference in a new issue