toggle

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package toggle evaluates feature-toggle targeting rules and composes the per-harness settings fragments a release carries for client-axis toggles. Rule evaluation is pure and deterministic; percent rollouts hash through internal/assign (the single hashing source) under a per-toggle salt.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bucket

func Bucket(name, subject string) int

Bucket is the subject's bucket in [0, assign.Buckets) for the toggle.

func Delta

func Delta(p string, base, on []byte) ([]byte, error)

Delta returns the JSON delta turning base into on for the file at p, or nil when they are equal. A nil base means the toggle adds the file.

func Merge

func Merge(p string, base []byte, deltas ...[]byte) ([]byte, error)

Merge applies JSON deltas to the file at p (base nil = absent) and returns the re-encoded file.

func Salt

func Salt(name string) string

Salt is the hash namespace of a toggle's percent rollouts.

Types

type Decision

type Decision struct {
	Name string `json:"name"`
	On   bool   `json:"on"`
	// Rule is the index of the deciding rule, -1 when the default applied.
	Rule int `json:"rule"`
	// Killed: the name is on the signed kill list, so On is false whatever the rules say.
	Killed bool     `json:"killed,omitempty"`
	Why    string   `json:"why"`
	Trace  []string `json:"trace"`
}

Decision is one toggle's outcome with the reasoning behind it.

func Eval

func Eval(name string, def bool, rules []policy.ToggleRule, s Subject, killed bool) Decision

Eval walks rules in order; the first match decides, else def applies. A killed toggle is off regardless. The trace lists every condition checked.

func EvalAll

func EvalAll(org *policy.Org, s Subject, killed []string) []Decision

EvalAll evaluates every toggle of org for s; killed names are forced off.

type Subject

type Subject struct {
	ID     string   `json:"id"`
	Groups []string `json:"groups,omitempty"`
	Ring   string   `json:"ring,omitempty"`
}

Subject is who a toggle is evaluated for: the authenticated identity plus the ring it resolved to. Never built from client-supplied headers.

Jump to

Keyboard shortcuts

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