Skip to content

Commit fd74e7d

Browse files
committed
feat(webapp): boot global flags registry
1 parent 4fa0a0c commit fd74e7d

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

apps/webapp/app/entry.server.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ import { registerRunChangeNotifierHandlers } from "./services/realtime/runChange
4343
import { sessionsReplicationInstance } from "./services/sessionsReplicationInstance.server";
4444
(globalThis as Record<string, unknown>).__sessionsReplicationInstance =
4545
sessionsReplicationInstance;
46+
import { globalFlagsRegistry } from "./v3/globalFlagsRegistry.server";
47+
(globalThis as Record<string, unknown>).__globalFlagsRegistry = globalFlagsRegistry;
4648

4749
const ABORT_DELAY = 30000;
4850

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { singleton } from "~/utils/singleton";
2+
import { env } from "~/env.server";
3+
import { flags } from "~/v3/featureFlags.server";
4+
import type { FeatureFlagCatalog } from "~/v3/featureFlags";
5+
import { createReloadingRegistry } from "~/utils/reloadingRegistry.server";
6+
7+
/**
8+
* In-memory snapshot of the global feature flags, refreshed every
9+
* GLOBAL_FLAGS_RELOAD_INTERVAL_MS. `flags()` reads the DB-backed global values
10+
* (no per-org overrides). Read synchronously on the trigger hot path; callers
11+
* gate the first read on `waitUntilReady`.
12+
*/
13+
export const globalFlagsRegistry = singleton("globalFlagsRegistry", () =>
14+
createReloadingRegistry<Partial<FeatureFlagCatalog>>({
15+
name: "global-flags",
16+
intervalMs: env.GLOBAL_FLAGS_RELOAD_INTERVAL_MS,
17+
load: () => flags(),
18+
})
19+
);

0 commit comments

Comments
 (0)