eventbus

package
v1.61.0 Latest Latest
Warning

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

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

Documentation

Overview

Package eventbus is a tiny in-process publish/subscribe hub for the server to client push channel. The web layer publishes typed events (a coder started, a shell was renamed, the tab order changed) and the event stream handler fans them out to every connected browser over one SSE connection. The bus keeps no history: a fresh subscriber is caught up by the snapshot the stream handler pushes on connect, not by replay.

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 every current subscriber. Safe for concurrent use.

func New

func New() *Bus

New returns an empty bus.

func (*Bus) Publish

func (b *Bus) Publish(ev Event)

Publish delivers ev to every subscriber. A subscriber whose buffer is full is skipped rather than blocking the publisher, so one stalled browser never holds up a lifecycle handler.

func (*Bus) Subscribe

func (b *Bus) Subscribe() (<-chan Event, func())

Subscribe registers a channel and returns it together with a cancel func that must be called when the subscriber goes away.

type Event

type Event struct {
	Type string `json:"type"`
	Data any    `json:"data,omitempty"`
}

Event is one server to client message. Type names the kind ("terminals", "notifications"); Data is any JSON serialisable payload and may be nil for events that only signal "something changed, pull the fresh state".

Jump to

Keyboard shortcuts

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