readerpool

package
v0.56.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: Apache-2.0 Imports: 11 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 readerpool retains immutable object handles within a bounded process-wide budget.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append(ctx context.Context, namespace any, name string, dst []byte, off, n int64, open func() (Reader, error)) ([]byte, bool, error)

Append reads a clamped range into caller-owned storage without allocating a cursor lease.

func BeginMutation

func BeginMutation(namespace any, name string) func()

BeginMutation rotates scopes before publication; its callback rotates them again after publication, so new reads cannot retain an object opened mid-replacement.

func ID

func ID(ctx context.Context) uint64

ID identifies the operation's immutable generation without retaining its context.

func Rebind

func Rebind(ctx, from context.Context) context.Context

Rebind preserves an immutable owner while replacing operation values and cancellation.

func RelievePressure

func RelievePressure(err error) bool

RelievePressure reclaims a bounded batch of idle current-generation handles.

func Scoped

func Scoped(ctx context.Context) bool

Scoped reports whether a read belongs to an immutable object owner.

func Supported

func Supported(backend any) bool

Supported reports whether a backend participates in scoped file invalidation.

func Valid

func Valid(ctx context.Context) bool

Valid reports whether an operation can still open its generation.

Types

type Batch added in v0.55.0

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

Batch retains a bounded set of leases for one operation; reset it between parts. Reset and Close wait for reads using those leases.

func WithBatch added in v0.55.0

func WithBatch(ctx context.Context) (context.Context, *Batch)

WithBatch lets scoped Append calls reuse leases until Reset or Close.

func (*Batch) Close added in v0.55.0

func (b *Batch) Close() error

Close releases leases and refuses further reads through this batch.

func (*Batch) Reset added in v0.55.0

func (b *Batch) Reset() error

Reset releases the previous part's leases while retaining bounded bookkeeping.

type Reader

type Reader interface {
	io.Reader
	io.ReaderAt
	io.Seeker
	io.Closer
	Size() int64
}

Reader is an opened object with independent ranged reads.

func Open

func Open(ctx context.Context, namespace any, name string, open func() (Reader, error)) (Reader, bool, error)

Open reuses one immutable raw reader; namespace must be comparable. A full pinned budget declines reuse so the caller can use its ordinary ranged-read fallback.

type Scope

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

Scope owns immutable generations and protects idle handles from ordinary LRU eviction.

func NewScope

func NewScope() *Scope

NewScope creates an immutable object owner, initially unpinned.

func (*Scope) Acquire

func (s *Scope) Acquire()

Acquire protects idle handles from ordinary LRU eviction until Release.

func (*Scope) Close

func (s *Scope) Close() error

Close releases idle handles; outstanding leases keep their handles until closed.

func (*Scope) Context

func (s *Scope) Context(ctx context.Context) context.Context

Context attaches this immutable object owner to backend reads.

func (*Scope) Release

func (s *Scope) Release()

Release ends one pin.

func (*Scope) ResidentBytes

func (s *Scope) ResidentBytes() int64

ResidentBytes bounds scope and registered/retained reader bookkeeping.

Jump to

Keyboard shortcuts

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