events

package
v0.0.39 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterRoutes

func RegisterRoutes(e *echo.Echo, broker *Broker, authMiddleware *auth.Middleware)

Types

type Broker

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

Broker fans out events to all subscribed SSE connections.

func NewBroker

func NewBroker() *Broker

func (*Broker) Close added in v0.0.32

func (b *Broker) Close()

Close broadcasts shutdown to all current and future subscribers. Idempotent: safe to call multiple times.

func (*Broker) Done added in v0.0.32

func (b *Broker) Done() <-chan struct{}

Done returns a channel that is closed when Close is called. SSE handlers select on this channel alongside the request context so they exit promptly during server shutdown instead of blocking until the client disconnects.

func (*Broker) Publish

func (b *Broker) Publish(evt Event)

Publish sends an event to all subscribers. Slow subscribers that have a full buffer will have this event dropped (non-blocking send).

func (*Broker) Subscribe

func (b *Broker) Subscribe() chan Event

Subscribe returns a channel that receives all future published events. The caller must call Unsubscribe when done.

func (*Broker) Unsubscribe

func (b *Broker) Unsubscribe(ch chan Event)

Unsubscribe removes a subscriber channel and closes it.

type Event

type Event struct {
	Type string
	Data string
}

Event represents a server-sent event with a named type and JSON data.

func NewBulkDownloadProgressEvent added in v0.0.21

func NewBulkDownloadProgressEvent(jobID int, status string, current, total int, estimatedSizeBytes int64) Event

NewBulkDownloadProgressEvent builds a progress event for bulk download jobs.

func NewJobEvent

func NewJobEvent(eventType string, jobID int, status, jobType string, libraryID *int) Event

NewJobEvent builds an Event with the standard job payload format.

Jump to

Keyboard shortcuts

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