Feature-flag client supporting both remote and local (server-side) evaluation.
Local evaluation (local_evaluation: true) fetches flag DEFINITIONS once,
caches them in a GenServer with a 5-minute TTL, and evaluates each flag
deterministically on this process — the correct home for flag evaluation in a
server SDK and the cross-platform-identical algorithm shared with
web / iOS / Android.
Remote evaluation falls back to POST /experiment-config, which returns a
pre-evaluated feature_flags map for the given user.
Mirrors the Node SDK flags.ts.
Summary
Functions
Returns a specification to start this module under a supervisor.
Deterministic local flag evaluation (spec §D)
Evaluate every known flag for a user.
Get a flag's value for a user. Returns true/false for a simple flag, the
variant key string for a multivariate flag, or nil when the flag is unknown.
Get a flag's payload (variant config). Only meaningful under local evaluation.
Returns the matched variant's payload, else the flag-level payload, else nil.
Boolean view of get_feature_flag/4 (a variant string counts as ON).
Force a reload of the cached flag definitions (local mode).
Inject flag definitions directly, bypassing the network. Primarily for tests and for hosts that distribute definitions through their own channel.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec evaluate_locally( t :: %BilldogEng.Flags{ api_key: term(), definitions: term(), definitions_set: term(), enable_logging: term(), fetched_at: term(), local_evaluation: term(), transport: term() }, String.t(), String.t(), map() | nil ) :: boolean() | String.t()
Deterministic local flag evaluation (spec §D):
- Missing/inactive → false.
- ALL
targeting_rulesmust matchattributes, else false. - bucket = murmurhash3("{key}.{distinctId}") % 100; ON iff bucket < rollout.
- Multivariate: walk variants by cumulative rollout within the ON bucket.
Returns false (off), true (on, boolean) or the chosen variant key.
Exposed for direct use against an explicit definition map.
Evaluate every known flag for a user.
Get a flag's value for a user. Returns true/false for a simple flag, the
variant key string for a multivariate flag, or nil when the flag is unknown.
Get a flag's payload (variant config). Only meaningful under local evaluation.
Returns the matched variant's payload, else the flag-level payload, else nil.
Boolean view of get_feature_flag/4 (a variant string counts as ON).
@spec reload_feature_flag_definitions(pid()) :: :ok
Force a reload of the cached flag definitions (local mode).
Inject flag definitions directly, bypassing the network. Primarily for tests and for hosts that distribute definitions through their own channel.