The provider configuration
Optionallogger: ILogger
Optional logger for background-refill failures
Positive integer snapshot limit, default 10,000; least recently used contexts are evicted
Evaluates a flag against the cached snapshot for this context.
Flag name
Optionalcontext: FlagContext
Targeting context
The snapshot value, or the configured fallbackValue when this
context has not been evaluated yet (a background refill is scheduled)
Evaluates a flag by awaiting LaunchDarkly directly.
Unlike LaunchDarklyProvider.isEnabled this has no cold-context
caveat. It also refreshes the snapshot cache, so a later synchronous read
for the same context is answered from real state.
Flag name
Optionalcontext: FlagContext
Targeting context
The evaluated value, or the configured fallbackValue when the
client is unavailable
Builds the client (unless one was injected), waits for its initial connection, subscribes to flag updates, and prewarms the anonymous snapshot.
A connection that does not complete within initTimeoutSeconds is logged
and tolerated rather than thrown: a flag backend being briefly unreachable
should leave the application serving with fallback values, not refuse to
boot. The condition is reported through
LaunchDarklyProvider.status.
Reports whether the client is connected.
healthy: false with a detail when the client is absent or has
not completed initialization
Closes the client and drops every cached snapshot.
A
FlagProviderbacked by LaunchDarkly.The synchronous/asynchronous bridge. LaunchDarkly's server SDK evaluates flags locally against a ruleset it streams into the process, but every evaluation method it exposes is asynchronous, so it cannot directly satisfy the committed synchronous
IFeatureFlags.isEnabled. This provider bridges the two using the one synchronous read the SDK does offer:LDFlagsState.getFlagValue.LaunchDarklyProvider.isEnabledanswers from a per-context snapshot cache. On a cache miss — the first evaluation for a givenuserId— it returns the configuredfallbackValueand schedules a background refill, so every subsequent call for that user is answered from real LaunchDarkly state.start()prewarms the anonymous context, and an SDKupdateevent drops the whole cache.LaunchDarklyProvider.isEnabledAsynchas no such caveat: it awaitsboolVariationdirectly and is always correct.Choose the async method wherever a wrong answer on a cold context would matter.
Example
Since
0.2.0