Documentation
¶
Overview ¶
Package protocol implements the control-plane wire protocols.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyEnvelope = errors.New("empty JSend envelope")
ErrEmptyEnvelope indicates that an endpoint expected to return JSend data returned no response body.
Functions ¶
func UnmarshalJSend ¶
UnmarshalJSend unwraps and decodes a JSend success envelope using the endpoint-specific response type T.
Types ¶
type EnvelopeError ¶
type EnvelopeError struct {
Status string
Message string
Code int
Data json.RawMessage
}
EnvelopeError describes a valid JSend envelope whose status is not success.
func (*EnvelopeError) Error ¶
func (e *EnvelopeError) Error() string
type NDJSONDecoder ¶
type NDJSONDecoder[T any] struct { // contains filtered or unexported fields }
NDJSONDecoder incrementally decodes newline-delimited JSON. It also accepts SSE data lines and ignores SSE control and comment lines.
func NewNDJSONDecoder ¶
func NewNDJSONDecoder[T any](body io.ReadCloser) *NDJSONDecoder[T]
NewNDJSONDecoder returns a decoder that owns body. Call Close when stopping before io.EOF so the underlying HTTP connection is released.
func (*NDJSONDecoder[T]) Close ¶
func (d *NDJSONDecoder[T]) Close() error
Close closes the underlying response body. It is safe to call repeatedly.
func (*NDJSONDecoder[T]) Recv ¶
func (d *NDJSONDecoder[T]) Recv() (T, error)
Recv returns the next event. It returns io.EOF after a cleanly drained body.