1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! The [`Job`] trait: a serializable payload bound to one queue.
use ;
use crate::;
/// 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");
/// ```