pub struct Monitor { /* private fields */ }Expand description
Owns the servicing path and every watcher created through it.
Implementations§
Source§impl Monitor
impl Monitor
Sourcepub fn new() -> Result<Self>
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.
Sourcepub fn session(&self) -> (Session, Receiver)
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.
Sourcepub fn session_with_bound(&self, bound: NonZeroUsize) -> (Session, Receiver)
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.
Sourcepub fn quiesce(&self)
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.
Sourcepub fn watcher_count(&self) -> usize
pub fn watcher_count(&self) -> usize
How many subscriptions the monitor currently holds.
Sourcepub fn retry_mode(&self, watch: WatchId) -> Option<RetryMode>
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.
Sourcepub fn is_registered(&self, watch: WatchId) -> bool
pub fn is_registered(&self, watch: WatchId) -> bool
Whether a subscription is registered, established or not.
Sourcepub fn is_watching(&self, watch: WatchId) -> bool
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.
Sourcepub fn stop_reason(&self, watch: WatchId) -> Option<Error>
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).
Sourcepub fn is_faulted(&self, watch: WatchId) -> Option<bool>
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).
Sourcepub fn fault_detail(&self, watch: WatchId) -> Option<FaultDetail>
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.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Whether the monitor is still accepting requests.
Sourcepub fn shut_down(&self)
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).