Documentation
¶
Overview ¶
Package observable provides cross-cutting observability primitives (metrics, tracing, structured logging) shared across CoreC packages.
Index ¶
Constants ¶
const DefaultSubscriberBuffer = 128
DefaultSubscriberBuffer is the default buffer size for subscriber channels.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Observable ¶
type Observable[T any] struct { // contains filtered or unexported fields }
Observable is a generic fan-out event bus. It reads from a source channel and fans out to multiple subscribers.
func NewObservable ¶
func NewObservable[T any](source <-chan T) *Observable[T]
NewObservable creates a new Observable and starts the fan-out goroutine.
func (*Observable[T]) Dropped ¶
func (o *Observable[T]) Dropped() int64
Dropped returns the total number of messages dropped due to slow subscribers.
func (*Observable[T]) Subscribe ¶
func (o *Observable[T]) Subscribe() (events <-chan T, unsub func())
Subscribe returns a channel of events and an unsubscribe function.
func (*Observable[T]) SubscribeWithBuffer ¶
func (o *Observable[T]) SubscribeWithBuffer(size int) (events <-chan T, unsub func())
SubscribeWithBuffer is like Subscribe but lets the caller choose the subscriber channel buffer size. size <=0 falls back to DefaultSubscriberBuffer.