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

Copy Markdown View Source

Evaluation context for deterministic rollout bucketing.

A context is a plain map. The bucketing key is taken from the first present of :id, "id", :user_id, or "user_id". An empty or missing identifier buckets every caller to the same "anonymous" slot — supply a stable id to get per-caller bucketing.

Summary

Types

t()

A context map carrying the caller identity.

Functions

Compute the rollout bucket (0..99) for the given flag name and context.

Types

t()

@type t() :: %{optional(atom() | String.t()) => String.t()}

A context map carrying the caller identity.

Functions

bucket_for(name, context)

@spec bucket_for(String.t(), t() | map()) :: 0..99

Compute the rollout bucket (0..99) for the given flag name and context.

Implements the same FNV-1a 32-bit hash used by the other TinyFlags ports so bucketing is identical across language ecosystems.