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
//! [`JobsRegistry`] — how the engine obtains the job handler registry.
//!
//! A job handler registry can be constructed in two ways:
//!
//! - **Static** ([`JobsRegistry::Static`]): built before the engine starts, with
//! no access to runtime state. The existing `.jobs(registry)` builder path.
//! - **Lifecycle** ([`JobsRegistry::WithDb`]): built *after* the engine
//! connects the `PgPool` at startup, so handlers can capture a `Db` clone
//! (or any handle derived from it). The `.jobs_with_db(closure)` builder
//! path.
//!
//! The A13 job-handler contract is `Fn(J) -> Fut` — the handler receives only
//! the typed payload, not application state. For a handler that needs the
//! database (the common dogfood case), the app supplies a closure
//! `Fn(&Db) -> Registry` that captures a `Db` clone into each handler; the
//! engine invokes it inside [`startup`](super::startup) after the pool
//! connects, then spawns the worker over the shared pool. This keeps the
//! certified `arcature-jobs` `Fn(J)` API unchanged; only the *registry-
//! construction* moment moves into the lifecycle.
//!
//! `jobs` implies `db` (see `Cargo.toml`), so `crate::db::Db` is always in
//! scope under this module's feature gate.
use Arc;
/// The job handler registry, either pre-built or lifecycle-built.
pub