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 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"`
}
Click to show internal directories.
Click to hide internal directories.