View Source Zexbox.Flags (Zexbox v0.4.0)

An Elixir wrapper around the LaunchDarkly Erlang client

To use this module you must have the LaunchDarkly Erlang client installed. To do so, add {:ldclient, "~> 2.0.0", hex: :launchdarkly_server_sdk} to your list of dependencies in mix.exs.

To start the client, call Zexbox.Flags.start/2 when starting your application with a map of config options and an optional tag:

iex> def start(_type, _args) do
iex>   Zexbox.Flags.start(%{sdk_key: "sdk-key", private_attributes: [:email]})

To make sure that the client shuts down, you should call Zexbox.Flags.stop/1 when your application shuts down:

iex> def stop(_state) do
iex>   Zexbox.Flags.stop()

Summary

Functions

Starts the LaunchDarkly client with the given config and tag.

Starts the LaunchDarkly client with the given config.

Starts the LaunchDarkly client with the given config and tag.

Stops the ldclient with the default tag.

Stops the ldclient with the given tag.

Gets the variation of a flag for the given key, context, and default value.

Gets the variation of a flag for the given key, context, default value, and tag.

Functions

@spec start() :: :ok | {:error, atom(), term()}

Starts the LaunchDarkly client with the given config and tag.

Examples:

  iex> Zexbox.Flags.start(%{sdk_key: "sdk-key"}, :my_tag)
  :ok

  iex> Zexbox.Flags.start(%{sdk_key: "sdk-key"}, :my_tag)
  {:error, {:already_started, #PID<0.602.0>}}
@spec start(map()) :: :ok | {:error, atom(), any()}

Starts the LaunchDarkly client with the given config.

@spec start(map(), atom()) :: :ok | {:error, atom(), term()}

Starts the LaunchDarkly client with the given config and tag.

@spec stop() :: :ok

Stops the ldclient with the default tag.

@spec stop(atom()) :: :ok

Stops the ldclient with the given tag.

Link to this function

variation(key, context_key, default)

View Source
@spec variation(String.t(), map(), any()) :: any()

Gets the variation of a flag for the given key, context, and default value.

Link to this function

variation(key, context, default, tag)

View Source
@spec variation(String.t(), map(), any(), atom()) :: any()

Gets the variation of a flag for the given key, context, default value, and tag.

Examples:

    iex> Zexbox.Flags.variation("my-flag", %{key: "user-key"}, false, :my_tag)
    true

    iex> Zexbox.Flags.variation("my-flag", %{key: "user-key"}, false, :my_tag)
    {:error, {:not_found, "my-flag"}}