bus

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package bus (piece ⑫) fans out domain events in memory: the web receives them over SSE, chat adapters re-edit messages already sent, and the scheduler re-plans reminders.

Index

Constants

View Source
const (
	SubscriptionCreated = "subscription.created"
	SubscriptionUpdated = "subscription.updated"
	SubscriptionDeleted = "subscription.deleted"
	ChargeUpdated       = "charge.updated"
	PaymentMethodSaved  = "payment_method.saved"
	CategorySaved       = "category.saved"
	HouseholdUpdated    = "household.updated"
	// KeepAwakeUpdated: the keep-awake setting or its status changed.
	KeepAwakeUpdated = "keep_awake.updated"
)

Event types.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

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

Bus is a non-blocking in-memory pub/sub. A slow subscriber loses events (its channel is buffered); consumers must refetch on gaps, as SSE clients do on reconnect (ADR 0013).

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(buffer int) (<-chan Event, func())

Subscribe returns a channel of events and a function to stop receiving.

type Event

type Event struct {
	Type           string    `json:"type"`
	HouseholdID    string    `json:"householdId"`
	SubscriptionID string    `json:"subscriptionId,omitempty"`
	ChargeID       string    `json:"chargeId,omitempty"`
	EntityID       string    `json:"entityId,omitempty"`
	ActorLabel     string    `json:"actor,omitempty"`
	AuditID        string    `json:"auditId,omitempty"`
	At             time.Time `json:"at"`
}

Event describes something that changed.

Jump to

Keyboard shortcuts

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