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
//! Celers-backed load sensor.
//!
//! [`CelersLoadSensor`] wraps a closure that yields a `celers_core::WorkerStats`
//! snapshot. The closure approach decouples the sensor from any specific celers
//! transport (AMQP, Redis, in-memory) and allows the caller to bridge any API surface.
use ;
/// Load sensor backed by a `celers_core::WorkerStats` closure.
///
/// The closure is called on every `sense()` invocation; expensive broker I/O
/// should be cached or rate-limited inside the closure itself.
///
/// # Example
///
/// ```rust,no_run
/// # #[cfg(feature = "load")]
/// # {
/// use oxirouter::context::CelersLoadSensor;
/// use celers_core::WorkerStats;
///
/// let sensor = CelersLoadSensor::new(|| {
/// // Replace with real broker inspection call
/// WorkerStats {
/// total_tasks: 1000,
/// active_tasks: 5,
/// succeeded: 990,
/// failed: 5,
/// retried: 2,
/// uptime: 3600.0,
/// loadavg: Some([0.3, 0.25, 0.2]),
/// memory_usage: Some(256 * 1024 * 1024),
/// pool: None,
/// broker: None,
/// clock: None,
/// }
/// });
/// # }
/// ```
+ Send + Sync,