go-ws/README.md
Snider 21fb545772
All checks were successful
Security Scan / security (push) Successful in 11s
Test / test (push) Successful in 39s
chore: add Go repo norms (badges, contributing, lint, taskfile, editorconfig)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-23 06:45:51 +00:00

1.7 KiB

Go Reference License: EUPL-1.2 Go Version

go-ws

WebSocket hub for real-time streaming in Go. Implements the hub pattern with centralised connection management, named channel pub/sub, token-based authentication on upgrade, client-side reconnection with exponential backoff, and a Redis pub/sub bridge for coordinating broadcasts across multiple hub instances. The envelope pattern with a per-bridge source ID prevents loop amplification when the Redis bridge is in use.

Module: forge.lthn.ai/core/go-ws Licence: EUPL-1.2 Language: Go 1.25

Quick Start

import "forge.lthn.ai/core/go-ws"

hub := ws.NewHub()
go hub.Run(ctx)

// Mount on any HTTP mux
http.HandleFunc("/ws", hub.Handler())

// Send process output to subscribers of "process:abc"
hub.SendProcessOutput("abc", "output line")

// Redis bridge for multi-instance coordination
bridge, _ := ws.NewRedisBridge(hub, ws.RedisConfig{Addr: "localhost:6379"})
bridge.Start(ctx)

Documentation

  • Architecture — hub pattern, channel subscriptions, authentication, Redis bridge, envelope loop prevention
  • Development Guide — prerequisites, test patterns, coding standards
  • Project History — completed phases with commit hashes, known limitations

Build & Test

go test ./...
go test -race ./...
go test -bench=. -benchmem ./...
go build ./...

Licence

European Union Public Licence 1.2 — see LICENCE for details.