ws

package
v0.22.2 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hub

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

Hub manages websocket clients and broadcasts events.

func NewHub

func NewHub(logger *slog.Logger, providers Providers) *Hub

NewHub constructs a websocket hub.

func (*Hub) Handle

func (h *Hub) Handle(w http.ResponseWriter, r *http.Request)

Handle upgrades the connection and keeps it registered until closed.

func (*Hub) PublishEvent

func (h *Hub) PublishEvent(ev history.Event)

PublishEvent broadcasts a history event and derived updates.

func (*Hub) Start

func (h *Hub) Start(ctx context.Context, subscribe func(int) (<-chan history.Event, func()))

Start subscribes to history updates and broadcasts them.

type Providers

type Providers struct {
	Heartbeats    func() []service.HeartbeatSummary
	Receivers     func() []service.ReceiverSummary
	History       func() []history.Event
	HeartbeatByID func(string) (service.HeartbeatSummary, bool)
	ReceiverByKey func(string, string, string) (service.ReceiverSummary, bool)
}

Providers supply snapshot data for websocket clients.

Jump to

Keyboard shortcuts

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