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
51
52
53
54
55
56
57
58
59
use Duration;
use async_trait;
use CancellationToken;
use crateResult;
/// A schedulable unit of work.
///
/// Implementors must be `Send + Sync + 'static` because the scheduler holds
/// each job behind an `Arc<dyn Job>` and runs it from a `tokio::spawn`'d
/// task.
///
/// Avoid implementing `Job` for types that carry mutable state — store
/// per-run progress in the `JobStore` (so it survives crashes) or in a
/// shared `Arc<Mutex<…>>` owned outside the job.
/// Cadence for a job.
///
/// `Cron` carries a 6-field cron expression (`sec min hour dom mon dow`)
/// per the [`cron`](https://crates.io/crates/cron) crate's syntax —
/// covers time-windowed cadences like
/// `0 */10 10-21 * * Mon-Fri` (every 10 min, 10:00–21:59, weekdays).
/// Validated server-side before persistence; the Scheduler treats an
/// unparseable expression as "do not fire" and logs a warning.
/// Per-run context handed to `Job::run`.
///
/// Carries the host's cancellation token (so long-running work can
/// cooperate with shutdown) and the current attempt count from
/// `job_state` (so a job can decide to skip expensive recovery work
/// on retry).