stream

package
v0.4.6 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	TypeStreamOpen  = "gonimbus.stream.open.v1"
	TypeStreamChunk = "gonimbus.stream.chunk.v1"
	TypeStreamClose = "gonimbus.stream.close.v1"
)
View Source
const DefaultMaxLineBytes = 1 << 20

Variables

This section is empty.

Functions

This section is empty.

Types

type ByteRange

type ByteRange struct {
	Start int64 `json:"start"`
	End   int64 `json:"end"`
}

type Chunk

type Chunk struct {
	StreamID string `json:"stream_id"`
	Seq      int64  `json:"seq"`
	NBytes   int64  `json:"nbytes"`
	Offset   *int64 `json:"offset,omitempty"`
}

type ChunkEvent

type ChunkEvent struct {
	Header Chunk
	Body   io.ReadCloser
}

type Close

type Close struct {
	StreamID string `json:"stream_id"`
	Status   string `json:"status"`
	Chunks   int64  `json:"chunks"`
	Bytes    int64  `json:"bytes"`

	DurationNS *int64 `json:"duration_ns,omitempty"`
}

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

func (*Decoder) Next

func (d *Decoder) Next() (Event, error)

func (*Decoder) SetMaxLineBytes

func (d *Decoder) SetMaxLineBytes(n int)

type Event

type Event struct {
	Kind   EventKind
	Record output.Record
	Chunk  *ChunkEvent
}

type EventKind

type EventKind int
const (
	EventRecord EventKind = iota
	EventChunk
)

type Open

type Open struct {
	StreamID string `json:"stream_id"`
	URI      string `json:"uri"`
	DestKey  string `json:"dest_key,omitempty"`

	ETag         string     `json:"etag,omitempty"`
	Size         *int64     `json:"size,omitempty"`
	LastModified *time.Time `json:"last_modified,omitempty"`
	ContentType  string     `json:"content_type,omitempty"`
	Encoding     string     `json:"content_encoding,omitempty"`

	Range *ByteRange `json:"range,omitempty"`
}

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer emits a mixed-framing stream: - JSONL control-plane records (output.Record) terminated by '\n' - for chunk records, exactly N raw bytes follow immediately

Writer is safe for concurrent use.

func NewWriter

func NewWriter(w io.Writer, jobID, provider string) *Writer

func (*Writer) Close

func (sw *Writer) Close() error

func (*Writer) WriteChunk

func (sw *Writer) WriteChunk(ctx context.Context, hdr *Chunk, body io.Reader) error

WriteChunk writes a chunk header record and then copies exactly hdr.NBytes bytes from body.

Caller may pass an io.Reader that yields fewer bytes; this will be surfaced as io.ErrUnexpectedEOF.

func (*Writer) WriteClose

func (sw *Writer) WriteClose(ctx context.Context, closeRec *Close) error

func (*Writer) WriteOpen

func (sw *Writer) WriteOpen(ctx context.Context, open *Open) error

Jump to

Keyboard shortcuts

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