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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! Per-slot admission policies.
//!
//! The controller admits work by **slot**, not by task name.
//! At most one task may occupy a slot at a time.
//!
//! Use [`ControllerSpec::with_slot`](crate::ControllerSpec::with_slot) when several differently named tasks should share one admission lane.
//! A slot is the submission key returned by [`ControllerSpec::slot_name`](crate::ControllerSpec::slot_name).
//! If no slot is set, it defaults to the task name.
//!
//! ## Busy Slots
//!
//! A slot is busy while it is:
//! - `Terminating`: the task is being removed, and the controller waits for `TaskRemoved`,
//! - `Admitting`: the task was sent to the runtime, but `TaskAdded` is not seen yet,
//! - `Running`: the task is registered and running.
//!
//! When a new submission targets a busy slot, [`AdmissionPolicy`] decides what happens.
//!
//! ## Policy Summary
//!
//! | Policy | Busy slot behavior | Common use |
//! |---------------------------------------------------|------------------------------------------------------|--------------------------------------|
//! | [`Queue`](AdmissionPolicy::Queue) | Wait behind older queued work | Job queue, ordered pipeline |
//! | [`Replace`](AdmissionPolicy::Replace) | Keep the latest next task, supersede older next task | Debounce, latest deploy |
//! | [`DropIfRunning`](AdmissionPolicy::DropIfRunning) | Reject while busy | Periodic checks, skip duplicate work |
//!
//! ## Rejection
//!
//! Rejected submissions emit `ControllerRejected`.
//! If submitted through `submit_and_watch`, the waiter resolves to [`TaskOutcome::Rejected`](crate::TaskOutcome::Rejected).
/// Policy for handling a submission when its target slot is busy.
///
/// If the slot is idle, all policies admit the submission immediately.
/// This enum is non-exhaustive. Match with a wildcard arm.