Skip to content

Platform flags

The platform flags driver (PlatformFlags) connects the framework’s feature flags module directly to the FlowCatalyst platform control plane using the application’s existing PlatformClient service account.

No extra database tables and no Redis instance are required in the application:

  1. Definition sync: declared flags are included in DefinitionSync (CategoryFlags / Category.FLAGS) and synced to POST /api/applications/{app}/flags/sync.
  2. Snapshot pull: fetches GET /api/applications/{app}/flags/snapshot with If-None-Match so unchanged snapshots return 304 Not Modified with zero JSON parsing.
  3. Live invalidation: keeps a persistent SSE connection open to GET /api/applications/{app}/flags/watch, triggering an immediate conditional refresh whenever an operator or client admin changes a flag in the console, backed by a 30-second poll fallback.
  4. Delegated client overrides: implements the admin writer interface for client-managed flags by forwarding PUT / DELETE /api/applications/{app}/flags/{key}/clients/{clientId} with X-On-Behalf-Of carrying the signed-in user’s principal id.
fcDecl := flowcatalyst.Declare(app)
flagsDecl := flags.Declare(app, orders.ExpressCheckout, orders.Routing)
// In build:
fc, err := flowcatalyst.Build(ctx, b, fcDecl,
flowcatalyst.WithFlags(flagsDecl.Definitions()))
if err != nil {
return err
}
pf := flowcatalyst.PlatformFlags(fc.Client(),
flowcatalyst.WithFlagsPollInterval(30*time.Second))
appFlags, err := flagsDecl.Build(ctx, b, pf)

Pass pf to flagsadmin.New(appFlags, pf) to enable in-app client self-service toggles on CLIENT_MANAGED flags (operator-only mutations remain in the FlowCatalyst console).

The platform’s built-in platform:application-service role carries all three permissions scoped to the application’s own code and entitled clients:

Permission Used by
platform:application-service:flags:sync DefinitionSync (POST /api/applications/{app}/flags/sync)
platform:application-service:flags:read Load (GET .../snapshot) and Watch (GET .../watch)
platform:application-service:flags:client-override Delegated SetClientOverride / DeleteClientOverride (PUT/DELETE .../clients/{clientId})

Operator-level changes (kill switches, global targeting rules, locks, deleting orphaned flags) require platform:admin:flags:manage in the FlowCatalyst console and cannot be performed by an application service account.

  • Platform unreachable at start-up: by default (UseDefaultsAndRetry), start-up succeeds and flags evaluate to their code-declared defaults while PlatformFlags retries with backoff.
  • SSE stream disconnects: Watch reconnects automatically with exponential backoff and runs a conditional snapshot check on reconnect so no revision is missed.
  • Platform error while running: the last good immutable snapshot stays active in memory; fw_flags_refresh_errors_total{driver="platform"} increments and the "flags" health check reports DEGRADED once snapshot age exceeds the configured threshold (default 5 minutes).