stream

package
v0.7.49 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithDataRequired

func WithDataRequired[T any](dataRequired bool) func(*EventStream[T])

Types

type EventStream

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

func NewEventStream

func NewEventStream[T any](
	ctx context.Context,
	source io.Reader,
	unmarshaller func(se []byte) (T, error),
	sentinel string,
	opts ...func(*EventStream[T]),
) *EventStream[T]

func (*EventStream[T]) Close

func (es *EventStream[T]) Close() error

Close will release underlying resources held by an event stream. It must always be called.

func (*EventStream[T]) Err

func (es *EventStream[T]) Err() error

Err returns the first non-EOF error that was encountered

func (*EventStream[T]) Next

func (es *EventStream[T]) Next() bool

Next waits for the next event from a stream which will be available through the Value() method. It returns false when the stream is done or an error occurred. After this method returns false, the Err method is used to check for any errors that occurred while parsing the stream.

func (*EventStream[T]) Value

func (es *EventStream[T]) Value() *T

Value returns the most recent event that was generated from a call to Next

type EventType

type EventType interface {
	GetEventEncoding(event string) (string, error)
}

type ServerEvent

type ServerEvent struct {
	ID    *string         `json:"id,omitempty"`
	Event *string         `json:"event,omitempty"`
	Data  json.RawMessage `json:"data,omitempty"`
	Retry *int64          `json:"retry,omitempty"`
}

Jump to

Keyboard shortcuts

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