sse

package
v1.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package sse provides Server-Sent Events (SSE) implementation for A2A.

Index

Constants

View Source
const (
	// ContentEventStream is the MIME type for Server-Sent Events.
	ContentEventStream = "text/event-stream"

	// MaxSSETokenSize is the maximum size for SSE data lines (10MB).
	// The default bufio.Scanner buffer of 64KB is insufficient for large payloads
	MaxSSETokenSize = 10 * 1024 * 1024 // 10MB
)

Variables

This section is empty.

Functions

func ParseDataStream

func ParseDataStream(body io.Reader) iter.Seq2[[]byte, error]

ParseDataStream returns an iterator over the data blocks in an SSE stream.

Types

type SSEWriter

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

SSEWriter wraps http.ResponseWriter to provide SSE writing capabilities.

func NewWriter

func NewWriter(w http.ResponseWriter) (*SSEWriter, error)

NewWriter creates a new SSEWriter.

func (*SSEWriter) WriteData

func (w *SSEWriter) WriteData(ctx context.Context, data []byte) error

WriteData writes a data block to the SSE stream.

func (*SSEWriter) WriteHeaders

func (w *SSEWriter) WriteHeaders()

WriteHeaders writes the standard SSE headers.

func (*SSEWriter) WriteKeepAlive

func (w *SSEWriter) WriteKeepAlive(ctx context.Context) error

WriteKeepAlive writes an SSE comment to keep the connection alive.

Jump to

Keyboard shortcuts

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