stream

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 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 stream provides a pull-based, bounded stream contract over any CTX unary backend. Reads supply backpressure; no unbounded queue or replay exists.

Index

Constants

View Source
const ContractName = "ext.stream"
View Source
const MaxBatchBytes = 1 << 20
View Source
const MaxItems = 256

Variables

This section is empty.

Functions

func CloseMethod

func CloseMethod() author.Method[CloseRequest, Empty]

func Contract

func Contract() plugin.ContractRef

func OpenMethod

func OpenMethod() author.Method[OpenRequest, OpenResponse]

func ReadMethod

func ReadMethod() author.Method[ReadRequest, Batch]

Types

type Batch

type Batch struct {
	Items []json.RawMessage `json:"items"`
	Done  bool              `json:"done"`
}

type Client

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

Client represents one ephemeral stream. Serialize Read and Close calls. A failed read must not be retried: items may already have been consumed.

func Open

func Open(ctx context.Context, caller author.Caller, parameters json.RawMessage) (*Client, error)

func (*Client) Close

func (c *Client) Close(ctx context.Context) error

func (*Client) Read

func (c *Client) Read(ctx context.Context, limit int) (Batch, error)

type CloseRequest

type CloseRequest struct {
	ID string `json:"id"`
}

type Empty

type Empty struct{}

type OpenRequest

type OpenRequest struct {
	Parameters json.RawMessage `json:"parameters"`
}

type OpenResponse

type OpenResponse struct {
	ID string `json:"id"`
}

type Options

type Options struct {
	Capacity int
	MaxAge   time.Duration
	// Scope derives an authenticated subject/tenant key from host-owned context
	// or validated domain authority. A caller-controlled string alone is unsafe.
	Scope func(context.Context, plugin.Request) (string, error)
	Open  func(context.Context, plugin.Request, json.RawMessage) (Reader, error)
}

type ReadRequest

type ReadRequest struct {
	ID       string `json:"id"`
	Sequence uint64 `json:"sequence"`
	Limit    int    `json:"limit"`
}

type Reader

type Reader interface {
	Read(context.Context, int) ([]json.RawMessage, bool, error)
	Close() error
}

Reader must honor ctx, return at most limit items, and keep allocation bounded. Close must unblock Read and be safe concurrently with it. EOF may accompany a final nonempty batch. Factory-created resources must not use an invocation context as their lifetime: the service supplies a separate bounded lifetime.

type Service

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

func New

func New(opts Options) (*Service, error)

func (*Service) Close

func (s *Service) Close() error

func (*Service) Register

func (s *Service) Register(r *author.Registry) error

Jump to

Keyboard shortcuts

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