Foyn
Lab

Feature flags

Flags

One admin page turns features on and off in apps that share no code or database, and an app that can't reach the service runs on the defaults in its own code.

How an app reads its flags

  1. Declare flags in code

    Each flag has a key, a default and optional scopes, such as phemten's live and sandbox channels. A new feature's default is off.

  2. Poll with the declarations

    Every 30 seconds the app sends its declarations in one PUT and gets back what has been set. The same call restores flags the service has lost.

  3. Evaluate in memory

    A check reads the scope's override, else the flag's value, else the code default. No request waits on the service.

Failure and access rules

Under the hood

Endpoints
PUT /v1/<namespace>/declarations, GET /v1/<namespace>/flags
Snapshot
value and scopes per flag; null means unset
Limits
100 flags per app; names are lowercase words joined by hyphens, up to 48 characters
Token check
Cloudflare Access JWT, RS256; signature, issuer, audience and expiry required
Admin page
One script, allowed by its hash; frame-ancestors 'none', so no other site can frame it
Stack
Python, FastAPI and SQLite; the rules are in one module that does no IO