pub enum SessionEvent {
Connected,
Reconnected {
gap_ms: u64,
},
Lagged {
dropped: u64,
first_seq: u64,
last_seq: u64,
},
BookInvalidated {
market_id: String,
reason: InvalidationReason,
},
Error {
message: String,
},
}Expand description
Connection-level events, emitted on a channel separate from WsUpdate so
a reconnect is observable as a single global signal rather than per-market.
Variants§
Connected
Initial socket establishment.
Reconnected
Socket re-established after an observed outage. gap_ms is the
wall-clock interval between the last received message and this event.
Callers who maintain per-market books should discard them and wait for
the next WsUpdate::Snapshot for each subscribed market.
Lagged
Outbound dispatch channel overflowed — a slow consumer missed deltas.
Unlike tokio::sync::broadcast which silently skips ahead, openpx
raises this explicitly and invalidates every affected book, because
a missed delta corrupts book state in a way the caller cannot detect
from the stream alone.
BookInvalidated
A specific market’s book is no longer trustworthy. Caller should
discard its cache for that market_id and wait for the next
WsUpdate::Snapshot.
Error
A non-fatal error observed on the connection. The session continues; the caller is informed in case they want to log or alert.
Implementations§
Source§impl SessionEvent
impl SessionEvent
Sourcepub fn reconnected(gap: Duration) -> Self
pub fn reconnected(gap: Duration) -> Self
Construct a Reconnected event from a Duration-shaped gap. Saturating
cast at u64::MAX keeps the type stable for callers serializing to JSON.
Sourcepub fn error(err: WebSocketError) -> Self
pub fn error(err: WebSocketError) -> Self
Convenience constructor that stringifies the upstream error.
Trait Implementations§
Source§impl Clone for SessionEvent
impl Clone for SessionEvent
Source§fn clone(&self) -> SessionEvent
fn clone(&self) -> SessionEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more