Skip to main content

Monitor

Struct Monitor 

Source
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

Source

pub fn new(config: MonitorConfig) -> Monitor

A monitor with this configuration, settled as MonitorConfig describes. This is the one allocation.

Source

pub fn config(&self) -> &MonitorConfig

The configuration in use, after clamping.

Source

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.

Source

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.

Source

pub fn tripped(&self) -> bool

Whether a verdict has been Verdict::Degraded since the last Monitor::reset.

Source

pub fn reset(&self)

Forget every outcome and open the latch.

An observer running at the same time may land an outcome in a slot this has already cleared, which is one outcome kept from before the reset, or in one it has not reached yet, which is one outcome lost.

Trait Implementations§

Source§

impl Debug for Monitor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Monitor

Source§

fn default() -> Monitor

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.