Botica.Flags.Flag (Botica v2.1.0)

Copy Markdown View Source

Struct representing a single feature flag.

Fields

  • :name — Atom identifier (e.g. :new_dashboard)
  • :enabled — Whether the flag is on. For rollout flags this is the master switch; individual users are gated by the rollout percentage.
  • :default — Fallback value when the flag is queried but not defined. Most flags use default: false; if you want safe-by-default for risky features, use default: false.
  • :description — Optional human-readable explanation
  • :rollout0..100 percentage of users that get the feature when enabled: true. nil means binary on/off (no gradual rollout).
  • :created_at — When the flag was first defined
  • :updated_at — Last modification timestamp

Summary

Functions

Creates a new Flag with the given attributes. Fills timestamps automatically.

Types

t()

@type t() :: %Botica.Flags.Flag{
  created_at: DateTime.t(),
  default: boolean(),
  description: String.t() | nil,
  enabled: boolean(),
  name: atom(),
  rollout: non_neg_integer() | nil,
  updated_at: DateTime.t()
}

Functions

new(name, opts \\ [])

@spec new(
  atom(),
  keyword()
) :: t()

Creates a new Flag with the given attributes. Fills timestamps automatically.

Examples

iex> Botica.Flags.Flag.new(:beta, default: false)
%Botica.Flags.Flag{name: :beta, enabled: false, default: false, ...}

iex> Botica.Flags.Flag.new(:rate_limiting, default: false, rollout: 25)
%Botica.Flags.Flag{name: :rate_limiting, rollout: 25, ...}