AgentXM.Examples.TinyFlags.VariantFlag (AgentXM Example TinyFlags v0.1.0)

Copy Markdown View Source

A feature flag whose treatment is one of a fixed set of named variants.

Variants are listed in declaration order. Without :default the first variant is the default. Without :rollout the default variant is returned for every caller. With :rollout, percentages of traffic are allocated to variants by deterministic bucketing; the total must not exceed 100, every rollout key must be a declared variant, and each percentage must be in 0..100.

Summary

Functions

Construct a variant flag.

Like new/2 but raises ArgumentError on invalid input.

Types

t()

@type t() :: %AgentXM.Examples.TinyFlags.VariantFlag{
  default: String.t(),
  rollout: %{optional(String.t()) => 0..100} | nil,
  variants: [String.t(), ...]
}

Functions

new(variants, opts \\ [])

@spec new(
  [String.t(), ...],
  keyword()
) :: {:ok, t()} | {:error, term()}

Construct a variant flag.

variants is a non-empty list of non-empty, unique strings.

Options:

  • :default — default variant (must be one of variants).
  • :rollout — map of variant => percentage allocating traffic.

new!(variants, opts \\ [])

@spec new!(
  [String.t(), ...],
  keyword()
) :: t()

Like new/2 but raises ArgumentError on invalid input.