pub struct WsDispatcher { /* private fields */ }Expand description
Producer handle held by exchange WS implementations. Owns the sender halves of both channels so the implementation can emit updates and session events directly.
The receiver halves are held in Mutex<Option<...>> and handed out
exactly once via take_updates() / take_session_events(). This
enforces the take-once contract on the consumer side.
Implementations§
Source§impl WsDispatcher
impl WsDispatcher
Sourcepub fn new(config: WsDispatcherConfig) -> Self
pub fn new(config: WsDispatcherConfig) -> Self
Create a new dispatcher. The returned dispatcher owns the send halves
of both channels and the (one-shot) receive halves; consumers fetch
streams exactly once via take_updates() / take_session_events().
Sourcepub fn take_updates(&self) -> Option<UpdateStream>
pub fn take_updates(&self) -> Option<UpdateStream>
Take ownership of the consumer-side update stream. Returns None if
already taken — the receiver is single-consumer by contract; cloning
would silently split messages between holders.
Sourcepub fn take_session_events(&self) -> Option<SessionStream>
pub fn take_session_events(&self) -> Option<SessionStream>
Take ownership of the consumer-side session stream.
Sourcepub fn try_send_update(&self, update: WsUpdate) -> bool
pub fn try_send_update(&self, update: WsUpdate) -> bool
Emit an update. Returns true if delivered. On Err(TrySendError::Full)
the update is dropped and the caller is expected to follow up with a
SessionEvent::Lagged + one or more BookInvalidated events — this
is the correctness contract that distinguishes 0.2 from 0.1’s
silent-skip broadcast behavior.
Sourcepub async fn send_session(&self, event: SessionEvent)
pub async fn send_session(&self, event: SessionEvent)
Emit a session event. Unlike updates, these are always delivered via
send; the session-event channel is sized generously and losing an
event (e.g. a missed Reconnected) is worse than a brief await.