pub struct ClusterEventPublisher { /* private fields */ }Expand description
Deployment-global cluster-event broadcaster with a monotonic seq stamper.
Implementations§
Source§impl ClusterEventPublisher
impl ClusterEventPublisher
Sourcepub fn new(capacity: NonZeroUsize) -> Self
pub fn new(capacity: NonZeroUsize) -> Self
Build a publisher over a fresh bounded broadcast channel of capacity.
capacity is the operator-configured websocket.cluster_broadcast_capacity
(validated non-zero at startup), so this never receives a zero.
Sourcepub fn emit<F>(&self, build: F) -> ClusterEvent
pub fn emit<F>(&self, build: F) -> ClusterEvent
Stamp and broadcast one cluster event.
build receives the publisher-allocated ClusterEventMeta (carrying the
next monotonic cluster_seq and the observation instant) and returns the
fully-formed event. The return value is the broadcast event (for tests);
a send with no live subscribers is not an error (the calm single-node
case has no dashboard attached).
Sourcepub fn subscribe(
&self,
after_seq: u64,
) -> BoxStream<'static, Result<ClusterEvent, ClusterStreamLagged>>
pub fn subscribe( &self, after_seq: u64, ) -> BoxStream<'static, Result<ClusterEvent, ClusterStreamLagged>>
Subscribe to the live cluster delta stream, suppressing any delivered
delta with cluster_seq <= after_seq.
after_seq dedups the splice seam: the cluster subscription attaches this
receiver BEFORE reading the priming snapshot (gap-free splice), so the
live stream may carry a delta the snapshot already reflects (one with
cluster_seq <= snapshot.as_of_seq). Passing after_seq = as_of_seq
suppresses exactly those already-applied deltas. Like every tokio
broadcast receiver, this sees only events sent AFTER it attaches — there
is no replay of pre-subscription history, which is why a lagged reconnect
re-requests a full snapshot rather than resuming.
A receiver that falls behind the bounded buffer yields one
Err(ClusterStreamLagged) with the skipped count and then closes —
the same lag contract as the workflow path, surfaced typed, never silent.
Sourcepub fn current_seq(&self) -> u64
pub fn current_seq(&self) -> u64
The next cluster_seq that will be assigned (i.e. one past the last
stamped). Used by the snapshot path to stamp as_of_seq consistently with
the live stream the subscriber spliced onto.
Trait Implementations§
Source§impl Clone for ClusterEventPublisher
impl Clone for ClusterEventPublisher
Source§fn clone(&self) -> ClusterEventPublisher
fn clone(&self) -> ClusterEventPublisher
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ClusterEventPublisher
impl !UnwindSafe for ClusterEventPublisher
impl Freeze for ClusterEventPublisher
impl Send for ClusterEventPublisher
impl Sync for ClusterEventPublisher
impl Unpin for ClusterEventPublisher
impl UnsafeUnpin for ClusterEventPublisher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoMaybeUndefined<T> for T
impl<T> IntoMaybeUndefined<T> for T
Source§fn into_maybe_undefined(self) -> MaybeUndefined<T>
fn into_maybe_undefined(self) -> MaybeUndefined<T>
Source§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
Source§fn into_option(self) -> Option<T>
fn into_option(self) -> Option<T>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request