Documentation
¶
Overview ¶
Package sse provides a dependency-free server-sent events presentation fanout adapter for runtime/contracts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 (*Hub) ClientCount ¶
ClientCount returns the number of currently connected clients.
func (*Hub) RevokeAudience ¶ added in v0.12.0
RevokeAudience disconnects currently connected clients whose server-owned audience label set includes every provided label. Include a session-specific label in WithAudienceFromRequest to revoke one active browser session.
func (*Hub) SendPresentationEvents ¶
SendPresentationEvents broadcasts presentation events to connected clients. Non-presentation events are ignored.
type Option ¶
type Option func(*Hub)
Option configures a Hub.
func WithAudienceFromRequest ¶ added in v0.8.0
WithAudienceFromRequest assigns one or more server-owned audience labels to a connecting client. Empty labels make the client receive broadcast events only. Do not read audience labels from client-controlled query parameters without authenticating them first.
func WithBufferSize ¶
WithBufferSize sets each client's queued message buffer. Non-positive values keep the default.
func WithReplayLimit ¶ added in v0.12.0
WithReplayLimit keeps the last limit presentation events in memory and replays events after the browser's Last-Event-ID on reconnect. Non-positive values disable replay.
func WithRetryMillis ¶ added in v0.12.0
WithRetryMillis sets the browser EventSource reconnect delay advertised by the stream. Non-positive values keep the default one-second delay.