Help us shape the future of Go! Take the 2026 Go Developer Survey

stream

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package stream owns producer joining and streaming response I/O.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Channel

func Channel(
	writer http.ResponseWriter,
	request *http.Request,
	values <-chan []byte,
	done <-chan error,
	encode func([]byte) []byte,
	policy Policy,
) error

Channel renews deadlines before commitment and each write, propagating every flush failure after commitment without consuming another value.

func Event

func Event(value []byte) []byte

Event frames one SSE value, normalizing CRLF and bare CR to prevent field injection. It retains the final empty data line so EventSource preserves the payload's trailing newline rather than consuming it as framing.

func Identity

func Identity(value []byte) []byte

Identity returns value unchanged for plain streams.

func Sequence

func Sequence(
	writer http.ResponseWriter,
	request *http.Request,
	values iter.Seq2[[]byte, error],
	encode func([]byte) []byte,
	policy Policy,
) error

Sequence copies borrowed slices before yield returns. Every started producer is joined, including cleanup, before its panic is re-raised on the caller.

Types

type Policy

type Policy struct {
	// Timeout resolves options only after capability checks and producer startup.
	Timeout func() time.Duration
	// NonFlushable is the public error returned by the legacy capability gate.
	NonFlushable error
}

Policy supplies the outer package's error identity and per-call settings.

Jump to

Keyboard shortcuts

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