sse

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	ID    string
	Event string
	Data  []byte
}

Event represents a server-sent event payload.

type Hub

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

Hub is a simple in-memory pub/sub for SSE topics.

func GetDataHub

func GetDataHub() *Hub

GetDataHub returns the SSE hub for data orchestration (SSESink).

func GetInternalHub

func GetInternalHub() *Hub

GetInternalHub returns the SSE hub for internal API notifications.

func (*Hub) ConfigureStream

func (h *Hub) ConfigureStream(topic string, cfg StreamConfig)

ConfigureStream sets the configuration for a specific stream.

func (*Hub) GetStreamConfig

func (h *Hub) GetStreamConfig(topic string) (StreamConfig, bool)

GetStreamConfig returns the configuration for a specific stream.

func (*Hub) Publish

func (h *Hub) Publish(topic string, ev Event)

Publish sends an event to all subscribers of the topic.

func (*Hub) Shutdown

func (h *Hub) Shutdown(ctx context.Context)

Shutdown stops the hub and closes all subscribers.

func (*Hub) Stream

func (h *Hub) Stream(ctx context.Context, topic string, buf int, fn func(Event) error) error

Stream streams events from a topic to the provided callback until context is done.

func (*Hub) Subscribe

func (h *Hub) Subscribe(topic string, buf int) (chan Event, func())

Subscribe adds a subscriber channel for the topic. Returns the channel and an unsubscribe function.

func (*Hub) WaitUntil

func (h *Hub) WaitUntil(topic string, timeout time.Duration) bool

WaitUntil waits until there is at least one subscriber for the topic or timeout.

type StreamConfig

type StreamConfig struct {
	AuthToken      string
	AllowedOrigins []string
}

StreamConfig holds security and other settings for an SSE stream.

Directories

Path Synopsis
transport

Jump to

Keyboard shortcuts

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