observation

package
v0.9.8-dev.8 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: GPL-3.0 Imports: 4 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 observation shares bounded, process-local read-only probes.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidated = errors.New("observation invalidated")

ErrInvalidated asks an owner to retry with its current observation identity.

Functions

func Fresh

func Fresh(ctx context.Context) bool

Fresh reports whether this request explicitly requires a fresh observation.

func WithFresh

func WithFresh(ctx context.Context) context.Context

WithFresh bypasses completed results, but permits joining a valid live probe.

Types

type Cache

type Cache[K comparable, V any] struct {
	// contains filtered or unexported fields
}

Cache holds at most one running probe, including a canceled native call that has not returned yet. Values must be immutable; callers clone mutable data.

func (*Cache[K, V]) Close

func (c *Cache[K, V]) Close()

Close cancels probes owned by this cache and rejects future requests.

func (*Cache[K, V]) Get

func (c *Cache[K, V]) Get(ctx context.Context, key K, ttl time.Duration, probe func(context.Context) (V, error)) (V, error)

Get reuses successful, unexpired results. A canceled waiter never owns the other waiters' execution context. Probe lifetime belongs to Cache.

func (*Cache[K, V]) Invalidate

func (c *Cache[K, V]) Invalidate()

Invalidate retires cached and in-flight observations.

Jump to

Keyboard shortcuts

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