pub struct Subscription { /* private fields */ }Expand description
A live subscription over a Query, resuming strictly after a start position.
Constructed by ReadHandle::subscribe. Owns a cursor
that only ever moves forward, so the subscription is a single long-lived object; it is not
meant to be cloned or resumed from a stale cursor.
Implementations§
Source§impl Subscription
impl Subscription
Sourcepub fn with_max_batch_events(self, max_batch_events: usize) -> Subscription
pub fn with_max_batch_events(self, max_batch_events: usize) -> Subscription
Overrides the per-batch event cap (default DEFAULT_MAX_BATCH_EVENTS).
Sourcepub fn position(&self) -> Position
pub fn position(&self) -> Position
The current resume position: the exclusive lower bound of the next read. Everything at or before it has been delivered. This is the value to persist for a durable subscriber that wants to resume across restarts.
Sourcepub fn poll_batch(&mut self) -> Result<Vec<(Position, Event)>, ReadError>
pub fn poll_batch(&mut self) -> Result<Vec<(Position, Event)>, ReadError>
Reads the matching events available now in (cursor, watermark], ascending, as an
owned batch bounded by the event cap. Does not block. An empty result means the
subscription has reached the live edge (caught up); call wait before
polling again.
The cursor advances only on genuine exhaustion: when the underlying Reads yields
None (it reached its pinned watermark) the cursor jumps to that watermark, past any
non-matching tail, so a selective query never re-scans it. When the batch cap is hit
instead, the cursor advances only to the last delivered position and the remainder
surfaces on the next call. It is never inferred from the batch size.
Sourcepub fn wait(&self) -> bool
pub fn wait(&self) -> bool
Blocks until the watermark advances past the cursor, returning true, or the store
shuts down, returning false. No timeout: use wait_timeout
when the caller must also observe an external signal (for example a server shutting
down while no events flow).
Sourcepub fn wait_timeout(&self, timeout: Duration) -> WaitOutcome
pub fn wait_timeout(&self, timeout: Duration) -> WaitOutcome
Like wait but bounded, so the caller regains control on TimedOut to
check its own state (the server uses this to notice shutdown on an idle subscription).
Sourcepub fn next_batch(
&mut self,
) -> Option<Result<Vec<(Position, Event)>, ReadError>>
pub fn next_batch( &mut self, ) -> Option<Result<Vec<(Position, Event)>, ReadError>>
Blocks until at least one matching event is available after the cursor, then returns it
as an owned ascending batch (bounded by the event cap). Returns None when the store
has shut down. Watermark advances that matched nothing are skipped internally (the
cursor still advances, so they are never re-scanned).
The ergonomic blocking form of poll_batch + wait,
for in-process consumers that do not need to interleave their own shutdown checks.