Documentation
¶
Overview ¶
Package observationstream provides a bounded, producer-owned observation queue without executing consumer code. Consumer panic, timeout, or detachment therefore cannot block producer completion; consumer cancellation and joining remain the responsibility of the layer that owns consumer execution.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidCapacity = errors.New("observation stream capacity must be positive")
ErrInvalidCapacity is returned when a stream cannot retain an observation.
Functions ¶
Types ¶
type Capacity ¶
type Capacity int
Capacity names the maximum number of observations retained while the consumer is not receiving.
type Completion ¶
Completion is the producer-proven snapshot at the stream's admission cut. Enqueued does not imply that a consumer received or processed an observation.
type Consumer ¶
type Consumer[T any] <-chan T
Consumer is the receive-only capability for a stream. Its direction prevents consumers from publishing observations or closing producer-owned admission.
type Producer ¶
type Producer[T any] struct { // contains filtered or unexported fields }
Producer owns publication and completion for one stream.
Producer values may be copied; every copy shares the same lifecycle. The zero value is inactive: publication is rejected and completion returns a zero cut.
func (Producer[T]) Complete ¶
func (producer Producer[T]) Complete() Completion
Complete closes admission and the consumer channel at one serialized cut. Every call returns the same producer-proven snapshot. Owners must quiesce all possible publishers before treating that cut as their final lifecycle state.
func (Producer[T]) RecordDropped ¶
RecordDropped accounts for observations lost by an upstream bounded producer. The owner transfers this count before completing the shared output stream.
func (Producer[T]) TryPublish ¶
TryPublish retains observation when admission is open and capacity remains. It never waits for the consumer. A false result means either the bounded capacity was exhausted before completion or publication began after the cut.