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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
//! Provides an operational view of current controller slots.
//!
//! [`SupervisorHandle::controller_snapshot`](crate::SupervisorHandle::controller_snapshot) reads slot owners,
//! states, queue depths, and state ages directly from the admission engine. Use the result for status pages,
//! metrics collection, diagnostics, and tests. It does not control admission or consume events.
//!
//! ```text
//! controller admission engine
//! │ tracked slot state
//! ▼
//! SupervisorHandle::controller_snapshot
//! │ reads slots one at a time
//! ▼
//! ControllerSnapshot ──► status, metrics, and diagnostics
//! ```
//!
//! Each slot is internally consistent. The full collection is a rolling view because slots are read one at a time.
//! It is not an atomic snapshot of the whole controller.
//! Use [`TaskWaiter`](crate::TaskWaiter) for a reliable final result of one watched submission.
use Arc;
use Duration;
use crateTaskId;
/// The admission and ownership state of a controller slot.
///
/// This status describes admission and ownership.
/// It does not always describe what the task body is doing at that moment.
///
/// This enum is non-exhaustive. Use a wildcard arm when matching it.
/// One controller slot captured at a single point during collection.
///
/// All fields come from one locked slot state. Another slot may be read at a different time.
///
/// This struct is non-exhaustive. Use `..` when matching it.
/// A rolling read-only view of the slots tracked by one controller.
///
/// Each [`SlotView`] reports one slot's owner, status, pending depth, and time in that status.
/// Entries appear in slot-key order.
///
/// # Consistency
///
/// The controller does not read every slot at one exact moment. A slot created during collection may be absent.
/// A removed slot may still appear. Any state can change after this value is returned.
/// Commands still waiting in the controller command queue do not appear until the controller processes them.
///
/// This struct is non-exhaustive. Use `..` when matching it.
///
/// # Examples
///
/// ```rust,no_run
/// # use taskvisor::prelude::*;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// # let supervisor = Supervisor::builder(SupervisorConfig::default())
/// # .with_controller(ControllerConfig::default())
/// # .build();
/// # let handle = supervisor.serve()?;
/// if let Some(snapshot) = handle.controller_snapshot().await {
/// println!(
/// "{} running, {} queued",
/// snapshot.running_count(),
/// snapshot.total_queued(),
/// );
///
/// if let Some(deploy) = snapshot.slot("deploy") {
/// println!("deploy: {:?}, queued: {}", deploy.status, deploy.queue_depth);
/// }
/// }
/// # Ok(())
/// # }
/// ```