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

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