bus

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 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 bus is the in-process SSE fan-out. Channels are "board" (global) and "task:{id}".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(m Message) string

Format renders a message in the SSE wire format.

Types

type Bus

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

Bus fans published messages out to every subscriber of a channel.

func New

func New() *Bus

New builds an empty bus.

func (*Bus) Publish

func (b *Bus) Publish(channel, event string, data any)

Publish delivers to every subscriber, dropping for any that is full — a slow client must never stall the scheduler, and the UI refetches on reconnect.

func (*Bus) Subscribe

func (b *Bus) Subscribe(channel string) chan Message

Subscribe registers a buffered channel on a channel name.

func (*Bus) Unsubscribe

func (b *Bus) Unsubscribe(channel string, ch chan Message)

Unsubscribe removes a subscriber and closes its channel.

type Message

type Message struct {
	ID    uint64 `json:"id"`
	Event string `json:"event"`
	Data  any    `json:"data"`
}

Message is one server-sent event.

Jump to

Keyboard shortcuts

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