Documentation
¶
Overview ¶
Package stream provides a pull-based, bounded stream contract over any Ext unary backend. Reads supply backpressure; no unbounded queue or replay exists.
Index ¶
- Constants
- func CloseMethod() author.Method[CloseRequest, Empty]
- func Contract() plugin.ContractRef
- func OpenMethod() author.Method[OpenRequest, OpenResponse]
- func ReadMethod() author.Method[ReadRequest, Batch]
- type Batch
- type Client
- type CloseRequest
- type Empty
- type OpenRequest
- type OpenResponse
- type Options
- type ReadRequest
- type Reader
- type Service
Constants ¶
const ContractName = "ext.stream"
const MaxBatchBytes = 1 << 20
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.
type CloseRequest ¶
type CloseRequest struct {
ID string `json:"id"`
}
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 Reader ¶
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.