Help us shape the future of Go! Take the 2026 Go Developer Survey

flags

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package flags implements Console's feature-flag evaluation engine. It wraps a store.FlagStore for persistence and resolves a flag to an Evaluation for a given subject deterministically: the same (flag, subject) pair always yields the same result, so a rollout is stable across calls and processes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine evaluates feature flags and provides CRUD passthrough to its store.

func New

func New(s store.FlagStore) *Engine

New returns an Engine backed by the given store.

func (*Engine) Create

func (e *Engine) Create(ctx context.Context, f core.Flag) error

Create persists a new flag.

func (*Engine) Delete

func (e *Engine) Delete(ctx context.Context, key string) error

Delete removes a flag by key.

func (*Engine) Evaluate

func (e *Engine) Evaluate(ctx context.Context, key string, subj core.Subject) (core.Evaluation, error)

Evaluate resolves key for subj. The result is deterministic per (flag, subject): bucketing is derived from a stable hash, never from randomness, so repeated calls are identical.

The pipeline is: load → enabled gate → scope gate → rollout gate → variant selection. The first gate that fails returns a disabled "off" Evaluation with a Reason naming the gate.

func (*Engine) Get

func (e *Engine) Get(ctx context.Context, key string) (core.Flag, error)

Get loads a flag by key.

func (*Engine) List

func (e *Engine) List(ctx context.Context) ([]core.Flag, error)

List returns all flags.

func (*Engine) SetEmitter

func (e *Engine) SetEmitter(fn func(core.Event))

SetEmitter installs an event sink (e.g. a notify.Dispatcher's Emit). Passing nil disables emission.

func (*Engine) Update

func (e *Engine) Update(ctx context.Context, f core.Flag) error

Update persists changes to an existing flag.

Jump to

Keyboard shortcuts

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