bus

package
v0.36.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

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

func New

func New(bufSize int) *Bus

func (*Bus) Dropped added in v0.21.0

func (b *Bus) Dropped() int64

Dropped returns the cumulative number of events dropped to full subscriber buffers, for observability.

func (*Bus) Publish

func (b *Bus) Publish(eventType string, properties any)

func (*Bus) SubscribeAll

func (b *Bus) SubscribeAll() <-chan Event

func (*Bus) Unsubscribe

func (b *Bus) Unsubscribe(ch <-chan Event)

type Event

type Event struct {
	Type string `json:"type"`
	// Seq is a monotonic, bus-global sequence number stamped on every published
	// event. Delivery to a slow subscriber is still lossy by design (a full
	// buffer drops rather than blocking the hot path), but the seq makes drops
	// DETECTABLE: a client that sees the sequence jump knows it missed events and
	// can resync. Control frames sent directly by the SSE handler
	// (server.connected/config/heartbeat) do not go through Publish and carry no
	// seq (0), so clients must ignore seq 0 for gap detection.
	Seq        int64           `json:"seq"`
	Properties json.RawMessage `json:"properties"`
}

Jump to

Keyboard shortcuts

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