View Source Zexbox.Flags (Zexbox v1.4.0)

An Elixir wrapper around the LaunchDarkly Erlang client

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

def start(_type, _args) do
  Zexbox.Flags.start()
  ...
end

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

def stop(_type, _args) do
  Zexbox.Flags.stop()
  ...
end

Summary

Functions

Starts the LaunchDarkly client using the :flags application config and the :default tag.

Starts the LaunchDarkly client with the given config or the given tag.

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 tag.

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

Functions

start()

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

Starts the LaunchDarkly client using the :flags application config and the :default tag.

Examples

iex> Zexbox.Flags.start()
:ok
iex> Zexbox.Flags.start()
{:error, :already_started, #PID<0.602.0>}

start(tag)

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

Starts the LaunchDarkly client with the given config or the given tag.

Examples

iex> Zexbox.Flags.start(%{sdk_key: "my-sdk-key"})
:ok
iex> Zexbox.Flags.start(%{sdk_key: "my-sdk-key"})
{:error, :already_started, #PID<0.602.0>}
iex>

start(config, tag)

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

Starts the LaunchDarkly client with the given config and tag.

Examples

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

iex> Zexbox.Flags.start(%{sdk_key: "my-sdk-key"}, :my_tag)
{:error, :already_started, #PID<0.602.0>}

stop()

@spec stop() :: :ok

Stops the ldclient with the default tag.

stop(tag)

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

Stops the ldclient with the given tag.

variation(key, context_key, default)

@spec variation(key :: String.t(), context :: map(), default :: any()) :: any()

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

Examples

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

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

variation(key, context, default, tag)

@spec variation(key :: String.t(), context :: map(), default :: any(), tag :: 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"}}