sse

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package sse provides a dependency-free server-sent events presentation fanout adapter for runtime/contracts.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoHub = errors.New("sse hub cannot be nil")

ErrNoHub is returned by helpers that require a hub but receive nil.

Functions

This section is empty.

Types

type Hub

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

Hub fans presentation events out to connected server-sent events clients.

func New

func New(options ...Option) *Hub

New creates an SSE hub.

func (*Hub) ClientCount

func (hub *Hub) ClientCount() int

ClientCount returns the number of currently connected clients.

func (*Hub) SendPresentationEvents

func (hub *Hub) SendPresentationEvents(ctx context.Context, events []contracts.EventEnvelope) error

SendPresentationEvents broadcasts presentation events to connected clients. Non-presentation events are ignored.

func (*Hub) ServeHTTP

func (hub *Hub) ServeHTTP(response http.ResponseWriter, request *http.Request)

ServeHTTP streams presentation events to one browser client.

type Option

type Option func(*Hub)

Option configures a Hub.

func WithBufferSize

func WithBufferSize(size int) Option

WithBufferSize sets each client's queued message buffer. Non-positive values keep the default.

Jump to

Keyboard shortcuts

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