FlagDash.Client (FlagDash SDK v0.1.0)

Copy Markdown View Source

Server-side FlagDash client with explicit endpoint tier and bounded TTL cache.

The client is a value, not a background process. It owns a private ETS table for cached reads and starts no timer while idle. Call close/1 when the process that created a long-lived client no longer needs it.

Summary

Types

context()

@type context() :: map()

option()

@type option() ::
  {:base_url, String.t()}
  | {:timeout, non_neg_integer()}
  | {:cache_ttl, non_neg_integer()}
  | {:region, String.t() | nil}
  | {:req_options, keyword()}

t()

@type t() :: %FlagDash.Client{
  base_url: String.t(),
  cache: :ets.tid(),
  cache_ttl: non_neg_integer(),
  region: String.t() | nil,
  req_options: keyword(),
  sdk_key: String.t(),
  timeout: non_neg_integer()
}

Functions

ai_config(client, file_name)

@spec ai_config(t(), String.t()) :: map() | nil

all_flags(client, context \\ %{})

@spec all_flags(t(), context()) :: map()

clear_cache(client)

@spec clear_cache(t()) :: :ok

close(client)

@spec close(t()) :: :ok

config(client, key, default \\ nil)

@spec config(t(), String.t(), term()) :: term()

experiment(client, key, context)

@spec experiment(t(), String.t(), context()) :: map() | nil

flag(client, key, context \\ %{}, default \\ false)

@spec flag(t(), String.t(), context(), term()) :: term()

flag_detail(client, key, context \\ %{}, default \\ nil)

@spec flag_detail(t(), String.t(), context(), term()) :: map()

get_config(client, key)

@spec get_config(t(), String.t()) :: map() | nil

list_ai_configs(client, opts \\ [])

@spec list_ai_configs(
  t(),
  keyword()
) :: [map()]

list_configs(client)

@spec list_configs(t()) :: [map()]

list_flags(client)

@spec list_flags(t()) :: [map()]

new(sdk_key, opts \\ [])

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

track_experiment_metric(client, event)

@spec track_experiment_metric(t(), map()) :: :ok | {:error, term()}

translation(client, key, locale, opts \\ [])

@spec translation(t(), String.t(), String.t(), keyword()) :: String.t()