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

flags

package
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package flags is GTB's wiring for dynamic feature flags (spec 0199 D10, D11): a features.Backend over the tool's own config store, so a service's flags can be flipped by editing its config with no vendor at all, and the controls registration that gives any backend the controller's lifecycle.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotABool = errors.NewSentinel("gtb.flags.not_a_bool", "flags: a feature's enabled value must be a boolean")

ErrNotABool reports a features.<id>.enabled value that is not a boolean.

Functions

func ConfigKey

func ConfigKey(id features.ID) string

ConfigKey is the config path the config-store backend reads for a feature: features.<id>.enabled. Absent means "no override".

func RegisterBackend

func RegisterBackend(ctrl *controls.Controller, name string, backend features.Backend)

RegisterBackend registers backend as a controls service named name, so its Init runs on the controller's start and its Close on stop (spec 0199 D10): a streaming vendor backend then opens and closes with the service that evaluates against it.

Types

type ConfigBackend

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

ConfigBackend resolves dynamic features from the tool's config store. It takes a fresh view on every Resolve, so a reload is visible at once and there is no cache to go stale (the spike measured the view read at 135 ns either way). A store reload is forwarded on Watch as "everything may have changed", since the store does not say which keys moved.

func NewConfigBackend

func NewConfigBackend(store *config.Store) *ConfigBackend

NewConfigBackend builds a backend over store.

func (*ConfigBackend) Close

func (b *ConfigBackend) Close() error

Close releases nothing: the store's lifecycle is the tool's.

func (*ConfigBackend) Init

Init subscribes to the store's reloads. The store is loaded before it is handed to anything, so the backend is ready at once.

func (*ConfigBackend) Ready

func (b *ConfigBackend) Ready() bool

Ready is always true: a store is loaded before anything holds it, so there is nothing to wait for. Init only wires the change notices.

func (*ConfigBackend) Resolve

Resolve reads features.<id>.enabled. An absent key is a clean Disabled answer (the fallback, the Set state, applies); a present boolean is the backend's answer; anything else is ErrNotABool.

func (*ConfigBackend) Watch

func (b *ConfigBackend) Watch(context.Context) <-chan features.Change

Watch emits a Change on every successful reload of the store.

Jump to

Keyboard shortcuts

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