policy

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: Apache-2.0 Imports: 1 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decision

type Decision int

Decision is the outcome of evaluating a Policy against current cache state.

const (
	DecisionFetch Decision = iota
	DecisionUseCurrent
	DecisionUsePinned
	// DecisionUseTag is the outcome of resolving readproof://ns/path@<tag>. It
	// is never produced by Evaluate: a tag ref bypasses policy entirely (the
	// caller asked for one exact snapshot), so the resolver sets it directly.
	DecisionUseTag
)

func Evaluate

func Evaluate(p Policy, hasCurrent bool, currentObservedAt, now time.Time) Decision

Evaluate decides whether a resolve should re-fetch from the source, reuse the current cached snapshot, or resolve to a pinned snapshot.

func (Decision) String

func (d Decision) String() string

type Policy

type Policy struct {
	Strategy Strategy
	// MaxAge applies only to StrategyAllowStale. Zero means no TTL (never
	// refresh once a snapshot exists).
	MaxAge time.Duration
	// PinnedSnapshotID applies only to StrategyPinned.
	PinnedSnapshotID string
}

Policy controls how a Resource's freshness is enforced during resolution.

type Strategy

type Strategy string

Strategy is one of the freshness strategies Readproof v0.1 supports.

const (
	StrategyRequireFresh Strategy = "require_fresh"
	StrategyAllowStale   Strategy = "allow_stale"
	StrategyPinned       Strategy = "pinned"
)

Jump to

Keyboard shortcuts

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