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 (*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 ¶
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 ¶
Subscribe returns a channel that receives all future published events. The caller must call Unsubscribe when done.
func (*Broker) Unsubscribe ¶
Unsubscribe removes a subscriber channel and closes it.
type Event ¶
Event represents a server-sent event with a named type and JSON data.