sse

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClientGone = errors.New("sse: client disconnected")

Functions

func Handler

func Handler(heartbeatInterval time.Duration, fn StreamFunc) http.HandlerFunc

func ResumeFrom

func ResumeFrom(r *http.Request) int64

func Write added in v0.4.1

func Write[T any](sw *Writer, event Event[T]) error

Write emits a typed SSE event and assigns its sequence ID centrally.

Types

type Event

type Event[T any] = tailkit.Event[T]

Event is the shared typed SSE event envelope.

type StreamFunc

type StreamFunc func(ctx context.Context, sw *Writer) error

type Writer

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

Writer emits server-sent events on a single HTTP response stream.

func NewWriter

func NewWriter(w http.ResponseWriter, r *http.Request) (*Writer, error)

func (*Writer) Error

func (sw *Writer) Error(msg string)

func (*Writer) Heartbeat

func (sw *Writer) Heartbeat() error

func (*Writer) Send

func (sw *Writer) Send(name string, data any) error

func (*Writer) SetSequence

func (sw *Writer) SetSequence(seq int64)

Jump to

Keyboard shortcuts

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