pub struct Tap { /* private fields */ }Expand description
The server’s tap. Cheap to clone; every clone is the same tap.
Implementations§
Source§impl Tap
impl Tap
Sourcepub fn observe_call(&self, fact: &CallFact<'_>) -> Result<bool, TapError>
pub fn observe_call(&self, fact: &CallFact<'_>) -> Result<bool, TapError>
Offers one call’s terminal outcome to the same sampled rings as publishes. No payload is retained, and the drainer is told after every lock is released.
§Errors
A tap lock is poisoned, or a measured hop cannot be represented.
Source§impl Tap
impl Tap
Sourcepub fn observe(&self, fact: &PublishFact<'_>) -> Result<bool, TapError>
pub fn observe(&self, fact: &PublishFact<'_>) -> Result<bool, TapError>
The hook: one publish return. With no subscription it is one atomic load and nothing else. Otherwise each matching subscription decides under its own lock whether to keep the message before anything is allocated for it; a kept message allocates its subject and its hops (and its reply-to, and a payload copy under a grant), and the drainer is woken once, after every tap lock is released. Answers whether any subscription kept it.
§Errors
Returns TapError::Poisoned when a tap lock is poisoned; any
subscription that kept the message before it still wakes the drainer.
Returns TapError::StationsDisagree when its station list was
refused: the message is kept, its receivers not recorded. Returns
TapError::HopsOutOfOrder when a hop was measured before the one
ahead of it: the message is kept with its hops as measured. Returns
TapError::HopBeforeFirstSight or TapError::HopOverflow when a
hop could not be carried: the message is kept without it. More than
one of these is TapError::Several, each named.
Source§impl Tap
impl Tap
Sourcepub fn new(node: &str, capacity: usize) -> Self
pub fn new(node: &str, capacity: usize) -> Self
A tap whose hops name node, with per-subscriber rings of capacity,
that wakes nobody: for a reader that drains when it chooses, as a test
does.
Sourcepub fn with_waker(node: &str, capacity: usize, waker: TapWaker) -> Self
pub fn with_waker(node: &str, capacity: usize, waker: TapWaker) -> Self
A tap that calls waker once per publish any subscription kept.
Fixed at construction, so the hot path reads it without a lock and
nothing can replace it.
Sourcepub fn with_depot(self, depot: bool) -> Self
pub fn with_depot(self, depot: bool) -> Self
This tap, on a server that keeps a persistent store when depot:
its kept durable messages then pass <node>.depot (lane brief
ruling 8).
Sourcepub fn reserved(&self, id: &str) -> Option<&'static str>
pub fn reserved(&self, id: &str) -> Option<&'static str>
The station id would collide with: this tap’s exchange (its node)
or its depot. A worker with such an identity names no station here.
Sourcepub fn subscribe(&self, filter: TapFilter) -> Result<TapSubscription, TapError>
pub fn subscribe(&self, filter: TapFilter) -> Result<TapSubscription, TapError>
Subscribes without payloads.
§Errors
Returns TapError::Poisoned when the subscriber list is poisoned.
Sourcepub fn subscribe_with(
&self,
filter: TapFilter,
grant: Option<PayloadGrant>,
) -> Result<TapSubscription, TapError>
pub fn subscribe_with( &self, filter: TapFilter, grant: Option<PayloadGrant>, ) -> Result<TapSubscription, TapError>
Subscribes, with payloads when grant is present.
§Errors
Returns TapError::Poisoned when the subscriber list is poisoned.
Sourcepub fn observations(&self) -> u64
pub fn observations(&self) -> u64
Publishes the hook has shown the tap while a subscription was live (a count pin: N ordinary publishes give N, the tap’s own records give zero).
Sourcepub fn subscriber_count(&self) -> usize
pub fn subscriber_count(&self) -> usize
Live subscriptions.
Sourcepub fn dropped_total(&self) -> u64
pub fn dropped_total(&self) -> u64
Messages evicted from every subscription’s ring since the tap was made.
Sourcepub fn name_station(
&self,
connection: u64,
station: &str,
) -> Result<(), TapError>
pub fn name_station( &self, connection: u64, station: &str, ) -> Result<(), TapError>
Names station as the station connection publishes as, from its
worker registration until Self::forget_station.
§Errors
Returns TapError::Poisoned when the station table is poisoned.
Sourcepub fn forget_station(&self, connection: u64) -> Result<(), TapError>
pub fn forget_station(&self, connection: u64) -> Result<(), TapError>
Forgets connection’s station, as its connection closes.
§Errors
Returns TapError::Poisoned when the station table is poisoned.
Sourcepub fn name_receiver(
&self,
subscriber: u64,
connection: u64,
) -> Result<(), TapError>
pub fn name_receiver( &self, subscriber: u64, connection: u64, ) -> Result<(), TapError>
Names connection as the owner of the subscription whose subscriber
pid is subscriber, until Self::forget_receiver.
§Errors
Returns TapError::Poisoned when the receiver table is poisoned.
Sourcepub fn forget_receiver(&self, subscriber: u64) -> Result<(), TapError>
pub fn forget_receiver(&self, subscriber: u64) -> Result<(), TapError>
Forgets the subscription whose subscriber pid is subscriber, as it
leaves its channel.
§Errors
Returns TapError::Poisoned when the receiver table is poisoned.
Sourcepub fn forget_receivers_of(&self, connection: u64) -> Result<(), TapError>
pub fn forget_receivers_of(&self, connection: u64) -> Result<(), TapError>
Forgets every subscription of connection, as it closes.
§Errors
Returns TapError::Poisoned when the receiver table is poisoned.
Sourcepub fn lend_recipients(&self) -> Result<Option<PublishRecord>, TapError>
pub fn lend_recipients(&self) -> Result<Option<PublishRecord>, TapError>
A buffer for a publish to record its recipients in, only while a subscription is live: with none it is one atomic load, no lock and no allocation, and the publish records nothing. A buffer lent comes from those given back, so it allocates only while the pool and each buffer grow to the widest concurrent fan-out.
§Errors
Returns TapError::Poisoned when the buffer pool is poisoned.
Sourcepub fn give_back(&self, buffer: PublishRecord) -> Result<(), TapError>
pub fn give_back(&self, buffer: PublishRecord) -> Result<(), TapError>
Takes back a buffer Self::lend_recipients lent, emptied, for the
next recording publish.
§Errors
Returns TapError::Poisoned when the buffer pool is poisoned.
Sourcepub fn recipients_lent(&self) -> u64
pub fn recipients_lent(&self) -> u64
Recipient buffers lent since the tap was made: publishes that asked the fan-out for their recipients.
Sourcepub fn unsubscribe_failures(&self) -> u64
pub fn unsubscribe_failures(&self) -> u64
Subscriptions whose drop found the subscriber list poisoned and so could not leave it.