logstream

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package logstream is an in-memory pub/sub for recon-run logs, backing the SSE endpoint (ports.LogStream). Each run keeps a bounded replay buffer of recent lines so a reconnecting client (SSE Last-Event-ID) can resume without gaps, then tails live lines. It carries no business logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

type Broker struct {
	// contains filtered or unexported fields
}

Broker implements ports.LogStream.

func NewBroker

func NewBroker(replayCap int) *Broker

NewBroker returns a broker retaining replayCap events per run (<=0 = default).

func (*Broker) Close

func (b *Broker) Close(runID string)

Close marks the run's stream ended: it emits a final Done event and closes every subscriber channel (so SSE handlers terminate). The replay buffer is kept so a late reconnect still gets the history + Done.

func (*Broker) Publish

func (b *Broker) Publish(runID, line string)

Publish appends a line to the run's stream and fans it out to live subscribers. A subscriber whose buffer is full is skipped for this live event (it remains in the replay buffer, so a reconnect recovers it) – the publisher never blocks.

func (*Broker) Subscribe

func (b *Broker) Subscribe(runID string, afterID int) (<-chan ports.LogEvent, func())

Subscribe replays buffered events with ID > afterID, then (if the stream is still open) registers for live events. The cancel func unsubscribes. If the stream is already closed, the returned channel carries the replay + a Done and is closed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL