pub trait Job:
Serialize
+ DeserializeOwned
+ Send
+ Sync
+ 'static {
type Queue: QueueSet;
const NAME: &'static str;
const QUEUE: Self::Queue;
// Provided method
fn retry_policy() -> Option<RetryPolicy> { ... }
}Expand description
A unit of work. Normally implemented via #[derive(Job)] from the macros
crate; the hand-written equivalent is:
use queuey_core::{Job, QueueConfig, QueueSet, RetryPolicy};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
enum AppQueues { Emails }
impl QueueSet for AppQueues {
fn all() -> &'static [Self] { &[AppQueues::Emails] }
fn name(&self) -> &'static str { "emails" }
fn config(&self) -> QueueConfig { QueueConfig::new(self.name()) }
}
#[derive(Serialize, Deserialize)]
struct SendEmail { to: String }
impl Job for SendEmail {
type Queue = AppQueues;
const NAME: &'static str = "SendEmail";
const QUEUE: AppQueues = AppQueues::Emails;
fn retry_policy() -> Option<RetryPolicy> { Some(RetryPolicy::exponential(5)) }
}
assert_eq!(SendEmail::QUEUE.name(), "emails");Required Associated Constants§
Required Associated Types§
Provided Methods§
Sourcefn retry_policy() -> Option<RetryPolicy>
fn retry_policy() -> Option<RetryPolicy>
Per-job retry override. None means “use the queue’s policy”.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".