Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewObservedSSEStream ¶
func NewObservedSSEStream(stream io.ReadCloser, observers ...Observer) io.ReadCloser
NewObservedSSEStream returns the original stream when there are no observers.
Types ¶
type EventFilter ¶
EventFilter is an optional Observer extension. Observers that consume only specific payloads can report disinterest from the raw event bytes; when no observer wants an event, the stream skips JSON decoding entirely. Filters must under-approximate disinterest only: an observer may still receive events it did not ask for when another observer wants them.
type ObservedSSEStream ¶
type ObservedSSEStream struct {
io.ReadCloser
// contains filtered or unexported fields
}
ObservedSSEStream proxies bytes unchanged while parsing SSE JSON events once and fanning them out to observers.
func (*ObservedSSEStream) Close ¶
func (s *ObservedSSEStream) Close() error
type Observer ¶
Observer receives parsed JSON SSE payloads in stream order. Implementations must treat the payload as read-only.
type StreamBuffer ¶
type StreamBuffer struct {
// contains filtered or unexported fields
}
StreamBuffer is a non-concurrent FIFO byte buffer for short-lived stream converters. It must not be copied after first use.
func NewStreamBuffer ¶
func NewStreamBuffer(initialCapacity int) StreamBuffer
func (*StreamBuffer) AppendBytes ¶
func (b *StreamBuffer) AppendBytes(data []byte)
func (*StreamBuffer) AppendString ¶
func (b *StreamBuffer) AppendString(data string)
func (*StreamBuffer) Consume ¶
func (b *StreamBuffer) Consume(n int)
func (*StreamBuffer) Len ¶
func (b *StreamBuffer) Len() int
func (*StreamBuffer) Read ¶
func (b *StreamBuffer) Read(p []byte) int
func (*StreamBuffer) Release ¶
func (b *StreamBuffer) Release()
Release returns the buffer's storage to the pool. No slice derived from the buffer (Unread, or bytes handed to a decoder that may alias its input) may be retained past this call: the storage is immediately reusable by another stream and retained views would see another request's data.
func (*StreamBuffer) Unread ¶
func (b *StreamBuffer) Unread() []byte