doc

package
v0.1.79 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action[K comparable] map[K]bool

Action describes docs that are loaded (true) or unloaded (false).

type Config

type Config[K comparable, V any] struct {
	// Create controls creating this V.
	// This is passed a cancel function which causes a shutdown of the context wrapping the V.
	// Use this for errors e.g., in the background task of this V.
	Create func(ctx context.Context, cancel context.CancelCauseFunc, key K) (inst V, err error)

	// Destroy controls destroying this V.
	// This is called when there is no hope of restoring the object.
	Destroy func(ctx context.Context, key K, inst V) (err error)

	// ShutdownDelay controls how long to keep the V alive after all clients disappear.
	ShutdownDelay time.Duration
}

type Holder

type Holder[K comparable, V any] interface {
	// For joins the instance with the given comparable Key while the given context is active.
	For(ctx context.Context, key K) (inst V, done <-chan error, err error)

	// Active returns an iterator which yields document changes over time.
	// The first yield will always contain the current set of active documents, even if that set is empty.
	Active(ctx context.Context, filter func(key K) (include bool)) (i iter.Seq[Action[K]])
}

Holder describes a keyed storage of instance objects.

func New

func New[K comparable, V any](config Config[K, V]) Holder[K, V]

New creates a new Holder, which is a keyed storage of instance objects that have lifetimes based on their users.

Jump to

Keyboard shortcuts

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