Help us shape the future of Go! Take the 2026 Go Developer Survey

websocket

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents a WebSocket client connection

type EventFilters

type EventFilters struct {
	// EventTypes filters events by type (e.g., test.begin, test.end)
	// Empty slice means all event types
	EventTypes []string

	// RunID filters events by run ID
	RunID string

	// TestID filters events by test ID
	TestID string

	// SuiteID filters events by suite ID
	SuiteID string
}

EventFilters holds filters for selective event streaming

type Hub

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

Hub manages WebSocket connections and broadcasts events to connected clients

func NewHub

func NewHub(logger *slog.Logger) *Hub

NewHub creates a new WebSocket hub

func (*Hub) GetMetrics

func (h *Hub) GetMetrics() HubMetrics

GetMetrics returns current hub metrics (safe for concurrent access)

func (*Hub) InitNATS

func (h *Hub) InitNATS(cfg NATSConfig) error

InitNATS initializes NATS consumer for the WebSocket hub

func (*Hub) LogMetrics

func (h *Hub) LogMetrics()

LogMetrics logs current metrics (useful for periodic health checks)

func (*Hub) Run

func (h *Hub) Run(ctx context.Context, cfg NATSConfig)

Run starts the hub's main loop

func (*Hub) ServeWS

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

ServeWS handles WebSocket requests from clients

type HubMetrics

type HubMetrics struct {
	ConnectedClients   int
	DroppedMessages    int64
	DroppedBroadcasts  int64
	BroadcastQueueSize int
	BroadcastCapacity  int
}

Metrics returns current hub metrics for monitoring

type NATSConfig

type NATSConfig struct {
	URL          string
	StreamName   string
	ConsumerName string
	BatchSize    int
	MaxWait      time.Duration
}

NATSConfig holds configuration for NATS WebSocket integration

Jump to

Keyboard shortcuts

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