Skip to content

live

etrack.providers.adapters.sink.live

providers/adapters/sink/live: LiveAdapter — every frame kept per thread for replay, and pushed to who watches.

A thread is a conversation: its frames, across runs, get a thread-wide offset (contiguous, from 0) and the last buffer of them are kept. watch(thread, after) replays what is kept past the cursor, then follows live — a client that reconnects with the last offset it saw misses nothing still buffered. A watcher that lags more than backlog frames is cut off rather than slowing the bus; threads beyond threads are evicted, least recently written first. threads() lists what is kept, the most recently written first: each thread's next offset, its runs and when it last wrote — what a viewer offers to pick from.

LiveAdapter

LiveAdapter(**given: Unpack[LiveConfig])

The live sink: the whole record, every phase, kept and pushed in memory.

Keyword arguments as LiveConfig names them; what is not given, ETRACK_LIVE_* fills (infra/defaults).

health async

health() -> bool

Always ready: the buffer lives in this process.

offset

offset(thread: str) -> int

The offset the thread's next frame will take: how many frames it has had.

send async

send(view: EventView) -> None

Keep the frame under its thread's next offset and push it to every watcher.

threads

threads() -> tuple[LiveSummary, ...]

Every kept thread that has written, the most recently written first.

watch async

watch(
    thread: str, after: int = -1
) -> AsyncIterator[LiveFrame]

The thread's kept frames past after, then every new one, until the watcher lags, is evicted or leaves.

LiveThread dataclass

LiveThread(
    buffer: deque[LiveFrame],
    offset: int = 0,
    runs: dict[str, None] = dict(),
    last: datetime | None = None,
    watchers: set[
        MemoryObjectSendStream[LiveFrame]
    ] = set(),
)

One conversation: its next offset, the frames kept, its runs, when it last wrote, and who watches it.