class DatabaseProvider
implements FlagProvider
Since 0.1.0

Database-backed flag provider that polls an injected IFlagStore.

Loads initial state via store.loadFlags() on start(), then polls at a configurable interval. On poll failure, keeps the last good snapshot, logs via the injected logger, and exposes unhealthy status().

Examples

Example 1

const provider = new DatabaseProvider(
  { store: myFlagStore, refreshIntervalMs: 60000 },
  ctx.runtime,
  ctx.logger,
);
await provider.start();

Constructors

DatabaseProvider(
options: { readonly store: IFlagStore; readonly refreshIntervalMs?: number; },
runtime: IRuntimeServices,
logger?: ILogger
)

Properties

readonly
type: "database"

Provider type identifier.

Methods

isEnabled(
flag: string,
context?: FlagContext
): boolean

Evaluates the flag against the current snapshot.

start(): Promise<void>

Loads initial state ONCE and arms the poll interval ONCE.

Returns status: healthy when the last poll succeeded; degraded when it failed.

stop(): Promise<void>

Stops the poll timer. Guards against stop()-before-arm (no-op if start was never called or the timer is already cleared).

Usage

import { DatabaseProvider } from "feature-flags-plugin/src/index.ts";