Expand description
rustio_feature_flags — a tiny project-side feature-flag
surface. Projects flip a named flag from the admin UI; project
code reads it via feature_enabled without paying for a
Postgres round-trip on every call.
Schema:
CREATE TABLE rustio_feature_flags (
key TEXT PRIMARY KEY,
enabled BOOLEAN NOT NULL DEFAULT FALSE,
description TEXT NOT NULL DEFAULT '',
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);Reads go through a process-local 60-second cache (mirrors the permissions cache pattern). The cache is per-key — a single flag flip refreshes only that key’s entry.
The admin UI at /admin/feature_flags lets administrators
create / toggle / describe flags. Project code calls
feature_enabled from request handlers, background jobs,
migrations — anywhere a Db is in scope.
Structs§
- Feature
Flag - One feature flag’s stored state. Surfaced by [
list_flags] for the admin UI; project code reads booleans viafeature_enabled.
Functions§
- ensure_
table - Ensure the
rustio_feature_flagstable exists. Idempotent. - feature_
enabled truewhen the named flag is set andenabled = TRUE. Missing keys read asfalse. Reads go through a 60-second per-key cache so hot paths stay cheap.- invalidate_
cache - Drop every cached entry. Called by [
set_flag] / [create_flag] so a fresh write is observable on the next read without waiting for the TTL.