ssestream

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: Apache-2.0 Imports: 8 Imported by: 32

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterDecoder

func RegisterDecoder(contentType string, decoder func(io.ReadCloser) Decoder)

Types

type Decoder

type Decoder interface {
	Event() Event
	Next() bool
	Close() error
	Err() error
}

func NewDecoder

func NewDecoder(res *http.Response) Decoder

type Event

type Event struct {
	Type string
	Data []byte
}

type Stream

type Stream[T any] struct {
	// contains filtered or unexported fields
}

func NewStream

func NewStream[T any](decoder Decoder, err error) *Stream[T]

func (*Stream[T]) Close

func (s *Stream[T]) Close() error

func (*Stream[T]) Current

func (s *Stream[T]) Current() T

func (*Stream[T]) Err

func (s *Stream[T]) Err() error

func (*Stream[T]) Next

func (s *Stream[T]) Next() bool

Next returns false if the stream has ended or an error occurred. Call Stream.Current() to get the current value. Call Stream.Err() to get the error.

	for stream.Next() {
		data := stream.Current()
	}

 	if stream.Err() != nil {
		...
 	}

Jump to

Keyboard shortcuts

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