The process that owns an instance's cache, and the API a config module delegates to.
Each use PhoenixFlags module starts its own Server, named after the
module. Reads go straight to :persistent_term and never call it; cached
writes go through it, so a write and a cache reload cannot interleave.
Summary
Functions
Returns all config entries grouped by category.
Returns audit log entries, newest first: every flag's, or one key's.
Returns a specification to start this module under a supervisor.
Returns the config for the given instance. Used by the UI to resolve actor.
Deletes a targeting rule by id. Its conditions go with it.
Returns the cached value for a config key.
Deletes stored flags the config module no longer declares, with their targeting rules, and returns the deleted keys.
Adds a targeting rule to a flag.
Returns the targeting rules for a flag, in evaluation order.
Updates a config entry and refreshes the cache.
Returns the variant assigned to identity for a :variant flag.
Functions
Returns all config entries grouped by category.
Returns audit log entries, newest first: every flag's, or one key's.
audit_log(MyApp.SystemConfig)
audit_log(MyApp.SystemConfig, "enable_benefits")
audit_log(MyApp.SystemConfig, limit: 50)
audit_log(MyApp.SystemConfig, "enable_benefits", limit: 50)Raises PhoenixFlags.Error unless the instance is configured with audit: true.
Returns a specification to start this module under a supervisor.
See Supervisor.
Returns the config for the given instance. Used by the UI to resolve actor.
Deletes a targeting rule by id. Its conditions go with it.
Returns {:error, :not_found} for an unknown id and {:error, :unavailable}
when the database cannot be reached. Pass actor: in opts for the audit log.
Returns the cached value for a config key.
Targeting rules are consulted first: if one matches the request context, its
value wins over the stored value. See PhoenixFlags.Target.
When cache_enabled: false, checks the process dictionary first
(for test overrides), then targeting rules, then falls back to a direct DB read.
Options
:context— attributes for targeting rules, overriding the process-scopedPhoenixFlags.Context. Given neither, targeting is skipped entirely.
Raises for a :variant flag: it holds a split rather than a single value, and
returning the struct would leak it into application code. Use variant/4.
Deletes stored flags the config module no longer declares, with their targeting rules, and returns the deleted keys.
Startup never deletes a row: during a rolling deploy the old and new releases disagree about which flags exist. Run this once every node runs code that no longer declares the flags.
Adds a targeting rule to a flag.
attrs takes :value and :conditions, and optionally :position:
put_target(MyApp.SystemConfig, "enable_benefits",
conditions: [[attribute: :company_id, operator: :in, values: [123]]],
value: "true"
)The value must be valid for the flag's type, checked with the same rules a
dashboard save goes through. :secret flags cannot be targeted — a rule value
would sit in the targets table as plaintext, defeating the encryptor.
Pass actor: in opts to name who added it in the audit log.
Returns the targeting rules for a flag, in evaluation order.
Updates a config entry and refreshes the cache.
When cache_enabled: false, runs in the caller's process for Ecto sandbox compatibility.
Accepts an optional :timeout (in milliseconds, default 5000). A write that
takes longer returns {:error, :timeout} rather than exiting, and may still
land — read the value back to learn which.
Returns the variant assigned to identity for a :variant flag.
Deterministic for a given identity, split and seed — see PhoenixFlags.Variant.
Cached, it is a :persistent_term read, a hash and a short list walk; the
split is parsed once when the cache loads.
Options
:default— returned when the flag does not exist, is not a:variantflag, the instance is not running, or the identity is unusable. Defaults tonil.:telemetry— whentrue, emits[:phoenix_flags, :variant, :assigned]with%{flag: key, identity: identity, variant: variant, instance: instance}as metadata, so exposures can be piped into your own analytics. Off by default to keep the read path free.:context— attributes for targeting rules, overriding the process-scoped context. A matching rule pins the caller to its variant, ahead of the split.:now— current time in milliseconds, for testing TTL rollover.