protocol

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package protocol implements the control-plane wire protocols.

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyEnvelope = errors.New("empty JSend envelope")

ErrEmptyEnvelope indicates that an endpoint expected to return JSend data returned no response body.

Functions

func UnmarshalJSend

func UnmarshalJSend[T any](body []byte) (T, error)

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.

Jump to

Keyboard shortcuts

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