Documentation
¶
Overview ¶
Package sse provides Server-Sent Events broadcasting for engram.
Index ¶
Constants ¶
View Source
const ( // WriteTimeout is the timeout for writing to SSE clients. // Prevents blocking on stale connections. WriteTimeout = 2 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Broadcaster ¶
type Broadcaster struct {
// contains filtered or unexported fields
}
Broadcaster manages SSE client connections and message broadcasting.
func NewBroadcaster ¶
func NewBroadcaster() *Broadcaster
NewBroadcaster creates a new SSE broadcaster.
func (*Broadcaster) AddClient ¶
func (b *Broadcaster) AddClient(w http.ResponseWriter) (*Client, error)
AddClient adds a new SSE client connection.
func (*Broadcaster) Broadcast ¶
func (b *Broadcaster) Broadcast(data interface{})
Broadcast sends a message to all connected clients. Uses non-blocking writes with timeout to prevent stale connections from blocking.
func (*Broadcaster) ClientCount ¶
func (b *Broadcaster) ClientCount() int
ClientCount returns the number of connected clients.
func (*Broadcaster) HandleSSE ¶
func (b *Broadcaster) HandleSSE(w http.ResponseWriter, r *http.Request)
HandleSSE handles an SSE connection request.
func (*Broadcaster) RemoveClient ¶
func (b *Broadcaster) RemoveClient(client *Client)
RemoveClient removes a client connection.
Click to show internal directories.
Click to hide internal directories.