View Source Zexbox.Flags (Zexbox v0.7.1)

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 and the :default 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

@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>}
@spec start(map()) :: :ok | {:error, atom(), any()}

Starts the LaunchDarkly client with the given config and the :default 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>}
@spec start(map(), 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>}
@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 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"}}
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"}}