sse

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package sse provides Server-Sent Events (SSE) support for streaming responses from neoma API handlers.

Index

Constants

This section is empty.

Variables

View Source
var WriteTimeout = 5 * time.Second

WriteTimeout is the deadline applied to each SSE write operation.

Functions

func Register

func Register[I any](api core.API, op core.Operation, eventTypeMap map[string]any, handler func(ctx context.Context, input *I, send Sender))

Register adds an SSE endpoint to the API. It configures the operation's response schema from the eventTypeMap and streams events via the handler's Sender callback.

Types

type Message

type Message struct {
	ID    int
	Data  any
	Retry int
}

Message represents a single Server-Sent Event with optional ID, data payload, and retry interval.

type Sender

type Sender func(Message) error

Sender is a function that sends a Server-Sent Event message to the client.

func (Sender) Data

func (s Sender) Data(data any) error

Data is a convenience method that sends a message containing only the given data payload.

Jump to

Keyboard shortcuts

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