ws

package
v0.23.4 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 10 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

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