featureflags

package
v1.786.220 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package featureflags is cloud's runtime evaluation seam over the Hanzo Insights feature-flag engine (hanzoai/insights `rust/feature-flags`, the PostHog-compatible /flags + /decide evaluator). It is NOT a second flag store: Insights OWNS flag definitions, targeting, rollout %, and the change/activity log; cloud only EVALUATES flags at runtime and surfaces the platform switches to the admin cockpit.

ONE flag engine, EVERY switch. The PLATFORM launch switches (waitlist, public signup, subsystem activation, gateway limits, network ids) are Insights feature flags; this package NAMES them (the registry below — key + category + the env var that supplies the fallback default) and reads their live value. Env is only the FALLBACK default; the Insights flag overrides. A subsystem calls Bool/Int/String and gets the hot value — a flip in the Insights flag UI takes effect within one cache TTL (default 15s) with NO redeploy.

FAIL-SAFE. When Insights is not configured (INSIGHTS_FLAGS_URL / INSIGHTS_PROJECT_ TOKEN unset) OR unreachable, evaluation degrades to the env fallback -> literal default — exactly today's behavior, zero regression. No secret is read here; the project token is injected from KMS into the process env by the deployment (the same WAITLIST_URL env convention clients/base's waitlist plugin reads), never hardcoded.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(key string) bool

Bool returns the live boolean value of a registered switch (Insights -> env -> default).

func Int

func Int(key string) int

Int returns the live integer value of a registered switch.

func Mount

func Mount(_ *zip.App, deps cloud.Deps) error

Mount builds the evaluation client from env (Insights base + KMS-injected project token) and installs it as the process-wide seam. It serves NO HTTP routes — it is the in-process read plane that subsystems and clients/admin consume. Disabled config is a no-op (env fallback only), never an error.

func Register

func Register(d Def)

Register adds a switch to the platform-flag registry. Any subsystem may call it (in its init) to surface its own flag in the cockpit — the registry is open, not hardcoded. A duplicate key REPLACES the prior def (last registration wins).

func String

func String(key string) string

String returns the live string value of a registered switch.

Types

type BoardView

type BoardView struct {
	Engine     string       `json:"engine"`
	Configured bool         `json:"configured"`
	ManageURL  string       `json:"manageUrl"`
	AuditURL   string       `json:"auditUrl"`
	Switches   []SwitchView `json:"switches"`
}

BoardView is the full control-plane read board: the engine status + a deep-link to the Insights flag manager (the ONE place a switch is edited) and its activity log (the native change audit), plus every switch's live value.

func Board

func Board() BoardView

Board evaluates every registered switch live and returns the cockpit read board.

type Client

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

Client evaluates Insights feature flags over the PostHog-compatible /flags endpoint, caching the whole response for one TTL (the hot-apply bound). Reads are lock-guarded and degrade to env/default when Insights is unconfigured or unreachable.

type Def

type Def struct {
	Key      string // the Insights feature-flag key (snake_case)
	Category string // Launch | Signup | Subsystems | Gateway | Network
	Label    string
	Desc     string
	Type     Type
	Env      string // env var supplying the fallback default (may be "")
	Default  string // literal fallback when neither Insights nor env has a value
	ReadOnly bool   // surfaced read-only (boot-time activation, network ids)
}

Def is ONE platform switch: an Insights feature-flag key qualified by the metadata the cockpit shows and the env var that provides the fallback default. This table is the ONE place the platform switches are named; Insights evaluates them.

func Defs

func Defs() []Def

Defs returns a snapshot of the registered switches in registration order.

type SwitchView

type SwitchView struct {
	Key         string `json:"key"`
	Category    string `json:"category"`
	Label       string `json:"label"`
	Description string `json:"description"`
	Type        string `json:"type"`
	Value       string `json:"value"`
	Source      string `json:"source"`
	Env         string `json:"env,omitempty"`
	ReadOnly    bool   `json:"readOnly"`
}

SwitchView is one platform switch as the admin cockpit renders it: the live value + where it came from (insights | env | default).

type Type

type Type string

Type is the switch kind the cockpit renders (and how the value is decoded).

const (
	TypeBool   Type = "bool"
	TypeInt    Type = "int"
	TypeString Type = "string"
)

Jump to

Keyboard shortcuts

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