Documentation
¶
Overview ¶
Package policy defines the Phase 23 policy interface. Policies run inside the reload pipeline AFTER decode and validation but BEFORE the atomic state swap, so a violation cleanly aborts the reload without breaking the failure-safe contract: the previous *State[T] remains in place and Get() callers see no glitch.
The interface is generic in T so a policy can inspect the strongly typed configuration directly — no map[string]any round-trip.
Heavy policy backends (OPA, CUE) live in the corresponding fastconf/policy/opa and fastconf/policy/cue submodules to keep the core dependency-free.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnyPolicy ¶
type AnyPolicy interface {
Name() string
EvaluateAny(ctx context.Context, cfg any, reason, tenant string) ([]Violation, error)
}
AnyPolicy is the type-erased shim used by the framework to keep the non-generic options.policies slice. End users never construct AnyPolicy directly — they call fastconf.WithPolicy(p) which uses Adapt under the hood.
type Input ¶
type Input[T any] struct { // Config is the freshly decoded, validated, but NOT-yet-published // configuration. The pointer is stable for the duration of the // Evaluate call. Config *T // Reason mirrors ReloadCause.Reason ("provider:vault", "watcher", ...). Reason string // Tenant carries the TenantManager id when applicable. Tenant string }
Input is the typed evaluation context passed to Policy.Evaluate. Fields are read-only — policies MUST NOT mutate Config.
type Policy ¶
type Policy[T any] interface { Name() string Evaluate(ctx context.Context, in Input[T]) ([]Violation, error) }
Policy is the contract every policy backend implements. Evaluate MUST be goroutine-safe and SHOULD return promptly; the manager invokes it inline on the reload goroutine.