Interface that providers must implement to resolve flag values for their particular backend or vendor.

Implementation for resolving all the required flag types must be defined.

interface Provider {
    events?: ProviderEventEmitter<AnyProviderEvent, Record<string, unknown>>;
    hooks?: Hook[];
    metadata: ProviderMetadata;
    runsOn?: Paradigm;
    status?: ProviderStatus;
    initialize?(context?: EvaluationContext): Promise<void>;
    onClose?(): Promise<void>;
    onContextChange?(oldContext: EvaluationContext, newContext: EvaluationContext): void | Promise<void>;
    resolveBooleanEvaluation(flagKey: string, defaultValue: boolean, context: EvaluationContext, logger: Logger): ResolutionDetails<boolean>;
    resolveNumberEvaluation(flagKey: string, defaultValue: number, context: EvaluationContext, logger: Logger): ResolutionDetails<number>;
    resolveObjectEvaluation<T>(flagKey: string, defaultValue: T, context: EvaluationContext, logger: Logger): ResolutionDetails<T>;
    resolveStringEvaluation(flagKey: string, defaultValue: string, context: EvaluationContext, logger: Logger): ResolutionDetails<string>;
    track?(trackingEventName: string, context: EvaluationContext, trackingEventDetails: TrackingEventDetails): void;
}

Hierarchy (view full)

Implemented by

Properties

events?: ProviderEventEmitter<AnyProviderEvent, Record<string, unknown>>

An event emitter for ProviderEvents.

ProviderEvents

hooks?: Hook[]

A provider hook exposes a mechanism for provider authors to register hooks to tap into various stages of the flag evaluation lifecycle. These hooks can be used to perform side effects and mutate the context for purposes of the provider. Provider hooks are not configured or controlled by the application author.

runsOn?: Paradigm

Represents where the provider is intended to be run. If defined, the SDK will enforce that the defined paradigm at runtime.

the SDK now maintains the provider's state; there's no need for providers to implement this field. Returns a representation of the current readiness of the provider.

Providers which do not implement this method are assumed to be ready immediately.

Methods

  • A function used to setup the provider. Called by the SDK after the provider is set if the provider's status is NOT_READY. When the returned promise resolves, the SDK fires the ProviderEvents.Ready event. If the returned promise rejects, the SDK fires the ProviderEvents.Error event. Use this function to perform any context-dependent setup within the provider.

    Parameters

    Returns Promise<void>

  • A handler function to reconcile changes made to the static context. Called by the SDK when the context is changed.

    Returning a promise will put the provider in the RECONCILING state and emit the ProviderEvents.Reconciling event.

    Return void will avoid putting the provider in the RECONCILING state and not emit the ProviderEvents.Reconciling event.

    Parameters

    Returns void | Promise<void>