streaming Package

Unified streaming primitive — <xref:EventStream> Protocol + streams registry.

Pick a backing once at app startup via one of the registry's three use_* configurators, then obtain stream instances anywhere in your process via await streams.get_or_create(id) and program against the <xref:EventStream> Protocol.

See docs/streaming-guide.md for the developer guide (registry API, backings, per-turn id convention, exception/wire mapping, third-party-impl peer-registry pattern).

Classes

EventStream

A multi-cast event stream.

Four data-flow methods: emit, close, subscribe, last_cursor. Lifecycle (create / lookup / destroy) is the registry's job (streams); the Protocol intentionally does NOT include a destructive method.

See docs/streaming-guide.md for the developer guide.

EventStreamClosedError

Raised when emit() is called on an already-closed stream.

The stream still exists; the caller cannot add more events. This is a server-side bug (the producer kept emitting after closing) and should be wire-mapped to 5xx, not 4xx.

EventStreamError

Base class for all EventStream-raised exceptions.

Lets callers except EventStreamError to catch any of the subclasses uniformly.

EventStreamNotFoundError

Raised when any operation references a stream id that is not currently a live stream.

unified the previously-distinct EventStreamNotFoundError (never registered) and EventStreamGoneError (registered then destroyed) into this single error type. Three independent reasons fire this:

  • the id was never registered (no get_or_create(id) ever ran)

  • the id was explicitly deleted via streams.delete(id)

  • the id's stream was Closed and its close-clock TTL (close_time + ttl_seconds) elapsed, causing the registry to auto-tombstone

Collapsing the two error types simplifies the developer-facing surface: either way, the right behavior is the same (subscribe to a new id, or treat this id as missing). It also stops leaking the registry's internal tombstone bookkeeping (whether an id was "previously alive" or "never seen") into the public API.

Wire-mapped to HTTP 404 Not Found.