eventbus

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT 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 eventbus is the typed in-process event bus through which background components meet (AGENTS.md section 4). Publish never blocks; each subscriber has a bounded buffer and its own overflow policy.

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 events out to subscribers.

func New

func New() *Bus

New returns an empty bus.

func (*Bus) Publish

func (b *Bus) Publish(e Event)

Publish delivers e to every subscriber without blocking.

func (*Bus) Subscribe

func (b *Bus) Subscribe(size int, policy Overflow) *Subscription

Subscribe registers a subscriber with a buffer of size (at least 1).

func (*Bus) Unsubscribe

func (b *Bus) Unsubscribe(s *Subscription)

Unsubscribe removes s and closes its channel (the bus is the sender, so it closes).

type DeviceState

type DeviceState struct {
	Device string
	State  string
}

DeviceState reports a device health change (online, offline, stale, unconfigured).

type Event

type Event interface {
	// contains filtered or unexported methods
}

Event is any published event; the concrete types are defined below.

type Overflow

type Overflow int

Overflow decides what happens when a subscriber's buffer is full.

const (
	DropNewest Overflow = iota // keep what is queued, drop the new event
	DropOldest                 // drop the oldest queued event to make room
)

Overflow policies.

type SiteChanged

type SiteChanged struct {
	Rev  int64
	Keys []string
}

SiteChanged reports a new configuration revision; Keys are the live keys of the new site (spec 9.3 site_changed).

type StatusChanged

type StatusChanged struct {
	Device   string
	Register string
	Code     uint64
	Level    string
	At       time.Time
}

StatusChanged reports a changed device status register.

type Subscription

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

Subscription receives events on C until Unsubscribe; the bus closes C then.

func (*Subscription) C

func (s *Subscription) C() <-chan Event

C returns the receive channel.

func (*Subscription) Dropped

func (s *Subscription) Dropped() uint64

Dropped returns the number of events lost to overflow.

type ValueChanged

type ValueChanged struct {
	Key string
	At  time.Time
}

ValueChanged reports a new live value of a key ("<meter>/<channel>").

Jump to

Keyboard shortcuts

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