pub struct Monitor { /* private fields */ }Expand description
The last window outcomes and whether they have tripped it.
Cheap to share by reference from any number of tasks. See the module documentation for what the comparison can and cannot tell you.
Implementations§
Source§impl Monitor
impl Monitor
Sourcepub fn new(config: MonitorConfig) -> Monitor
pub fn new(config: MonitorConfig) -> Monitor
A monitor with this configuration, settled as MonitorConfig
describes. This is the one allocation.
Sourcepub fn config(&self) -> &MonitorConfig
pub fn config(&self) -> &MonitorConfig
The configuration in use, after clamping.
Sourcepub fn observe(&self, applied: bool, success: bool)
pub fn observe(&self, applied: bool, success: bool)
Record one settled outcome: whether the request went out edited, and whether it got what the caller asked for.
The oldest outcome in the window makes room. The window is then judged,
so a monitor trips on the observation that crossed the line without
anyone asking for a Monitor::verdict.
Sourcepub fn verdict(&self) -> Verdict
pub fn verdict(&self) -> Verdict
Judge the window as it stands, and latch Monitor::tripped when it
is Verdict::Degraded.
The verdict describes the window now, so it reads healthy again once healthy outcomes have pushed the bad ones out. The latch does not.
Sourcepub fn tripped(&self) -> bool
pub fn tripped(&self) -> bool
Whether a verdict has been Verdict::Degraded since the last
Monitor::reset.