pub struct ConsoleHub { /* private fields */ }Expand description
The console’s state, owned by the connection services.
Implementations§
Source§impl ConsoleHub
impl ConsoleHub
Sourcepub fn agent_changed(&self) -> Result<(), ConsoleError>
pub fn agent_changed(&self) -> Result<(), ConsoleError>
Makes a real metadata change due without inventing a worker or a flow.
§Errors
The topology lock or revision counter is unavailable.
Source§impl ConsoleHub
impl ConsoleHub
Sourcepub fn tap_room(&self, channel: &str) -> Result<bool, TapError>
pub fn tap_room(&self, channel: &str) -> Result<bool, TapError>
Whether a new subscription to channel is within the live-tap limit:
always for a channel that is not a tap or whose tap is live.
§Errors
Returns TapError::Poisoned when the tap table is poisoned.
Sourcepub fn reserve_tap(&self, channel: &str) -> Result<bool, TapError>
pub fn reserve_tap(&self, channel: &str) -> Result<bool, TapError>
Admits a subscribe to channel against MAX_LIVE_TAPS and, for a
tap not yet live, reserves its slot in the same lock, so two racing
subscribes cannot both take the last slot. Answers false when no slot
is left. The attach that follows takes the reservation up;
Self::release_tap gives it back when the subscribe fails.
§Errors
Returns TapError::Poisoned when the tap table is poisoned.
Sourcepub fn release_tap(
&self,
channel: &str,
retire: impl FnOnce(&str) -> Result<(), ConsoleError>,
)
pub fn release_tap( &self, channel: &str, retire: impl FnOnce(&str) -> Result<(), ConsoleError>, )
Gives back one reservation of channel for a subscribe that failed
after admission. When it was the last and no tap is live there, the
tap channel admission registered is taken off the roster by retire,
under the taps lock, so no subscribe reserving the tap again can see
its entry go: a refused subscribe leaves the roster as it found it. A
failed retire queues the subject for the pump; a poisoned table is
counted as a detach failure.
Sourcepub fn attach(&self, channel: &str) -> Result<(), ConsoleError>
pub fn attach(&self, channel: &str) -> Result<(), ConsoleError>
Counts a subscription to channel. A new console.topology
subscriber makes the latest document due again, so it is sent the
whole topology (R7); the first to a console.tap.<target> starts that
target’s tap. Any other channel is ignored.
§Errors
Returns ConsoleError::TapLimit when a new tap would pass
MAX_LIVE_TAPS, or ConsoleError::Tap when a lock is poisoned;
either is counted in tap_attach_failures.
Sourcepub fn detach(&self, channel: &str) -> Result<(), TapError>
pub fn detach(&self, channel: &str) -> Result<(), TapError>
Uncounts a subscription to channel. The last one to leave a
console.tap.<target> stops that target’s tap and queues the channel
for roster removal by the next pump. Safe on the channel actor’s
thread: it takes only hub locks and wakes without waiting.
§Errors
Returns TapError::Poisoned when a lock is poisoned; counted in
tap_detach_failures.
Sourcepub fn attached_subjects(&self) -> Result<Vec<String>, TapError>
pub fn attached_subjects(&self) -> Result<Vec<String>, TapError>
Subjects with a live tap, sorted.
§Errors
Returns TapError::Poisoned when the tap table is poisoned.
Source§impl ConsoleHub
impl ConsoleHub
Sourcepub fn new(
device: &str,
model: TopologyModel,
wall: WallBase,
) -> Result<Self, ConsoleError>
pub fn new( device: &str, model: TopologyModel, wall: WallBase, ) -> Result<Self, ConsoleError>
A hub for device holding model, timing records from wall, with
a tap of the default capacity.
§Errors
Returns ConsoleError::EmptyDevice when device is blank.
Sourcepub fn with_capacity(
device: &str,
model: TopologyModel,
wall: WallBase,
capacity: usize,
) -> Result<Self, ConsoleError>
pub fn with_capacity( device: &str, model: TopologyModel, wall: WallBase, capacity: usize, ) -> Result<Self, ConsoleError>
As Self::new, with each tap subscriber’s ring holding capacity.
§Errors
Returns ConsoleError::EmptyDevice when device is blank.
Sourcepub fn counts(&self) -> ConsoleCountsSnapshot
pub fn counts(&self) -> ConsoleCountsSnapshot
Every console counter as it stands.
Sourcepub fn incarnation_started(&self, started: Instant) -> Result<(), TapError>
pub fn incarnation_started(&self, started: Instant) -> Result<(), TapError>
This server’s incarnation started at started; the topology’s uptime
runs from there and the next document says so.
§Errors
Returns TapError::Poisoned when the topology lock is poisoned.
Sourcepub fn suppressed(&self)
pub fn suppressed(&self)
Counts a dedup-suppressed re-publish, which is not tapped.
Sourcepub fn observe_failed(&self)
pub fn observe_failed(&self)
Counts a publish the tap could not observe (its lock was poisoned). The publish itself answered as it would without the console.
Sourcepub fn set_notifier(&self, notifier: TapWaker) -> Result<(), TapError>
pub fn set_notifier(&self, notifier: TapWaker) -> Result<(), TapError>
Installs the function that tells the publisher there is work. The
publisher calls Self::pump on its own thread when told.
§Errors
Returns TapError::Poisoned when the slot is poisoned.
Sourcepub fn wake_if_due(&self) -> Result<(), TapError>
pub fn wake_if_due(&self) -> Result<(), TapError>
Wakes the publisher when work is already waiting: a topology subscriber, a live tap or a tap to retire. The start of the console streams calls it, so a subscriber that arrived before the publisher ran is served, and an idle server is never woken.
§Errors
Returns TapError::Poisoned when a hub lock is poisoned.
Sourcepub fn emit(&self, change: TopologyChange) -> Result<(), TapError>
pub fn emit(&self, change: TopologyChange) -> Result<(), TapError>
Applies change to the held topology. A change that alters it makes
the document due, and wakes the publisher when someone subscribes.
§Errors
Returns TapError::Poisoned when the topology lock is poisoned; the
change is counted in topology_emit_failures.
Sourcepub fn pump(
&self,
out: &dyn ServerPublisher,
) -> Result<PumpReport, ConsoleError>
pub fn pump( &self, out: &dyn ServerPublisher, ) -> Result<PumpReport, ConsoleError>
Publishes what is due through out: the topology document when it
changed and someone subscribes, then each live tap’s records, a
tap’s kept records first and its ring drained only when none are
kept; then removes retired tap channels from the roster. A failed
publish keeps that record and the tap’s later ones for the next pump,
and the pump goes on to the other taps.
§Errors
Returns ConsoleError when a lock is poisoned or a record cannot be
encoded; publish failures are counted and reported, not returned.