featureflags

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownFeature = errors.New("unknown feature flag")

ErrUnknownFeature is returned when a caller references a flag that has not been registered.

Functions

func ContextWithFlags

func ContextWithFlags(ctx context.Context, flags Flags) context.Context

ContextWithFlags stores the resolved flags on the provided context.

func EnabledFromEnv

func EnabledFromEnv(environ []string) []string

EnabledFromEnv scans the current environment (or the provided list) for TORQUE_FEATURE_* values.

Types

type Definition

type Definition struct {
	Name        Name
	Description string
	Stage       Stage
	Default     bool
}

Definition tracks the metadata for a feature flag.

func DefinitionByName

func DefinitionByName(name Name) (Definition, bool)

DefinitionByName returns the definition for the provided feature.

func Definitions

func Definitions() []Definition

Definitions returns the full set of registered flags in alphabetical order.

func (Definition) EnvVar

func (d Definition) EnvVar() string

EnvVar returns the environment variable that toggles the flag (e.g. TORQUE_FEATURE_FOO).

type Flags

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

Flags captures the resolved state of all feature flags for a torque invocation.

func FromContext

func FromContext(ctx context.Context) Flags

FromContext extracts the feature flag set from a context. The return value is safe to use even when no flags were stored.

func Resolve

func Resolve(sources ...[]string) (Flags, error)

Resolve combines defaults plus explicit sources (CLI/config/env) into a Flags set.

func (Flags) Enabled

func (f Flags) Enabled(name Name) bool

Enabled reports whether the provided feature is on for the current process.

func (Flags) EnabledNames

func (f Flags) EnabledNames() []Name

EnabledNames returns the currently enabled flag names in alphabetical order.

type Name

type Name string

Name is the canonical identifier for a feature flag (kebab-case).

type Stage

type Stage string

Stage indicates the lifecycle of a feature flag.

const (
	StageExperimental Stage = "experimental"
	StageBeta         Stage = "beta"
	StageGA           Stage = "ga"
)

Jump to

Keyboard shortcuts

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