Documentation
¶
Overview ¶
Package resultstream provides durable, position-addressed result streams.
Index ¶
- Variables
- type Config
- type ExpandFunc
- type Observer
- type Page
- type Progressive
- type Registry
- func (r *Registry) Close()
- func (r *Registry) Discard(scope Scope, qid string) error
- func (r *Registry) Pull(ctx context.Context, scope Scope, qid string, n int) (*Page, error)
- func (r *Registry) ResolveDatabase(owner, qid, requested string) (string, error)
- func (r *Registry) SetObserver(observer Observer)
- func (r *Registry) Start(ctx context.Context, scope Scope, stream Stream, n int) (*Page, error)
- type RetainedBytesGrowthGuard
- type RetainedBytesReporter
- type Scope
- type Stream
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidQID = errors.New("invalid result stream qid") ErrExpiredQID = errors.New("result stream qid expired") ErrGoneQID = errors.New("result stream qid no longer exists") ErrCapacity = errors.New("result stream capacity exceeded") ErrDisabled = errors.New("result stream continuation is disabled") ErrInvalidScope = errors.New("invalid result stream scope") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Disabled bool
TTL time.Duration
MaxStreams int64
MaxStreamsPerOwner int64
MaxPageSize int
MaxRetainedBytes int64
MaxRetainedBytesPerOwner int64
}
Config bounds process-local durable result streams.
type ExpandFunc ¶
ExpandFunc returns the complete ranked prefix available at depth. The returned prefix must preserve every previously returned row at its index.
type Page ¶
type Page struct {
Rows [][]any
QID string
Position uint64
Next uint64
HasMore bool
Total *uint64
ExpiresAt time.Time
Metadata map[string]any
}
Page is an immutable view of one stream position. Rows must be treated as read-only by adapters.
type Progressive ¶
type Progressive struct {
// contains filtered or unexported fields
}
Progressive grows a replayable row prefix only when buffered rows cannot satisfy a pull. Expansion work runs without registry locks.
func NewProgressive ¶
func NewProgressive(initial [][]any, exhausted bool, initialDepth int, expand ExpandFunc) (*Progressive, error)
NewProgressive constructs a progressively expandable stream.
func (*Progressive) Close ¶
func (s *Progressive) Close() error
Close releases references retained by the stream.
func (*Progressive) Pull ¶
Pull returns at most n rows and performs enough geometric expansion to know whether another row exists.
func (*Progressive) SetRetainedBytesGrowthGuard ¶
func (s *Progressive) SetRetainedBytesGrowthGuard(growthOK func() bool)
SetRetainedBytesGrowthGuard installs admission checked before expansion is published. It is intended for the owning registry.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry owns signed qids and sharded process-local stream entries.
func NewRegistry ¶
NewRegistry constructs a registry with a random signing key and instance ID.
func (*Registry) Close ¶
func (r *Registry) Close()
Close releases every retained stream and rejects future operations.
func (*Registry) Pull ¶
Pull resolves a signed qid and invokes the stream without holding a registry shard lock.
func (*Registry) ResolveDatabase ¶
ResolveDatabase returns the database bound to a signed qid after validating its authenticated owner. A nonempty requested database must match exactly.
func (*Registry) SetObserver ¶
SetObserver replaces the optional lifecycle observer.
type RetainedBytesGrowthGuard ¶
type RetainedBytesGrowthGuard interface {
SetRetainedBytesGrowthGuard(func() bool)
}
RetainedBytesGrowthGuard allows a registry to approve retained growth before an expanding stream publishes its new replayable population.
type RetainedBytesReporter ¶
type RetainedBytesReporter interface {
RetainedBytes() int64
}
RetainedBytesReporter optionally reports memory retained for future pulls.