Skip to main content

Monitor

Struct Monitor 

Source
pub struct Monitor { /* private fields */ }
Expand description

Owns the servicing path and every watcher created through it.

Implementations§

Source§

impl Monitor

Source

pub fn new() -> Result<Self>

Create a monitor with an idle servicing path.

§Errors

Returns the error from creating the servicing path’s work object.

Source

pub fn session(&self) -> (Session, Receiver)

Open a session, returning it with the receiver its notifications arrive on.

Every watch created through the returned session delivers here (D-11), so a client chooses its routing once rather than per subscription: one session per consumer, and each consumer drains only what it asked for.

The notification queue is bounded at DEFAULT_BOUND; use Monitor::session_with_bound to choose.

Source

pub fn session_with_bound(&self, bound: NonZeroUsize) -> (Session, Receiver)

As Monitor::session, with an explicit notification-queue bound.

The bound counts notifications, not changes: one decoded completion is one batch (D-10), which may carry hundreds of records.

Source

pub fn quiesce(&self)

Block until every request submitted so far has been serviced.

Lets a caller observe resident state at a defined point rather than polling it: registration is asynchronous by design (D-2), so without this “no watcher was created” is indistinguishable from “not yet”.

Must not be called from inside the servicing path, which would be waiting on itself.

Source

pub fn watcher_count(&self) -> usize

How many subscriptions the monitor currently holds.

Source

pub fn retry_mode(&self, watch: WatchId) -> Option<RetryMode>

The retry mode a subscription registered with, if it is still live.

The mode is stated at registration and consumed by M5.3’s fault protocol; this is what makes it observable in the meantime.

Source

pub fn is_registered(&self, watch: WatchId) -> bool

Whether a subscription is registered, established or not.

Source

pub fn is_watching(&self, watch: WatchId) -> bool

Whether a subscription currently has a live watcher.

Distinct from Monitor::is_registered: a subscription whose target cannot be opened yet is registered but not watching (D-14). Also false once the routed watcher has stopped permanently (D-22) – being Subscription::Routed alone is not proof of liveness, since a stopped watcher stays routed until its subscription is cancelled.

Source

pub fn stop_reason(&self, watch: WatchId) -> Option<Error>

Why a subscription’s watcher stopped permanently, if it has (D-22). A watcher that is merely recovering (Monitor::is_faulted) reports nothing here – it is expected to resolve on its own (D-14).

Source

pub fn is_faulted(&self, watch: WatchId) -> Option<bool>

Whether a subscription’s watcher is currently working to re-establish itself (D-31): asking, awaiting an answer, or backed off. None if the subscription is not registered. A still-Pending subscription always counts, whether this is its first attempt or a later one after an outage – either way it is not currently delivering and the monitor is working to change that (D-14 is why neither case is ever terminal).

Source

pub fn fault_detail(&self, watch: WatchId) -> Option<FaultDetail>

The classification and raw code behind a subscription’s current fault, if any (D-79) – the same detail an interactive route was, or would have been, asked about. None if the subscription is not registered, still Pending (D-22’s initial open retry loop tracks no persistent detail of its own), or not currently faulted.

Source

pub fn is_running(&self) -> bool

Whether the monitor is still accepting requests.

Source

pub fn shut_down(&self)

Stop servicing and tear down every watcher, blocking until it is done.

Idempotent, so a caller may shut down explicitly and still let Drop run. After it returns, no handler and no completion callback is executing or can start, and every outstanding read has been cancelled (D-20).

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 Drop for Monitor

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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.