bus

package
v0.49.1 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package bus is the in-process fan-out for live frames: every stored event, session change, or alert is published once and delivered to every subscriber (WebSocket clients, the loop detector, tests). Slow subscribers are dropped rather than allowed to stall the writer — the UI can always catch up via REST.

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
}

Bus fans frames out to subscribers.

func New

func New() *Bus

New creates a bus.

func (*Bus) Publish

func (b *Bus) Publish(f Frame)

Publish delivers a frame to every subscriber without blocking.

func (*Bus) Subscribe

func (b *Bus) Subscribe(buffer int) *Subscriber

Subscribe registers a subscriber with the given buffer size.

func (*Bus) Subscribers

func (b *Bus) Subscribers() int

Subscribers returns the current subscriber count.

type Frame

type Frame struct {
	Type FrameType `json:"type"`
	Data any       `json:"data"`
}

Frame is what goes over /v1/live.

func (Frame) Marshal

func (f Frame) Marshal() ([]byte, error)

Marshal encodes the frame once for all subscribers.

type FrameType

type FrameType string

FrameType matches the WS contract: event | session | alert.

const (
	FrameEvent   FrameType = "event"
	FrameSession FrameType = "session"
	FrameAlert   FrameType = "alert"
	FrameStats   FrameType = "stats" // per-session stats snapshot; UI convenience
)

type Subscriber

type Subscriber struct {
	C chan Frame
	// contains filtered or unexported fields
}

Subscriber receives frames on C. Close it with Unsubscribe.

func (*Subscriber) Unsubscribe

func (s *Subscriber) Unsubscribe()

Unsubscribe removes the subscriber and closes its channel.

Jump to

Keyboard shortcuts

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