• HOME
  • INTEGRATIONS
  • SDKS
  • GUIDES
  • API DOCS
No results for ""
EXPAND ALL
launchdarkly.com

EDIT ON GITHUB

Erlang SDK reference

Read time: 1 minute
Last edited: Jun 18, 2021

Overview

This topic explains the basics of the LaunchDarkly Erlang server-side SDK and how it works.

To learn more, visit our Erlang SDK GitHub repository. The online API docs contain the programmatic definitions of every type and method. Additionally, you can clone and run sample applications using this SDK with Erlang, Elixir, and the Phoenix framework.

Getting started

Follow the steps below to get started using the LaunchDarkly SDK in your Erlang application.

First, you'll need to download the dependency using Rebar.

{deps, [
  {ldclient, "1.0.0", {pkg, launchdarkly_server_sdk}}
]}.

And then add it to your app.src file.

{applications,
  [kernel,
  stdlib,
  ldclient
]},

If you use Elixir you can download the dependency using Mix.

defp deps do
  [
    {:ldclient, "~> 1.0.0", hex: :launchdarkly_server_sdk}
  ]
end

After you install the SDK dependency, create an instance of the SDK.

Use a single instance
While the Erlang SDK supports starting multiple instances, most use cases only need a single instance. Consider using multiple instances only if you need to simultaneously access more than one environment. Do not start an instance every time you need to make a variation or other SDK call.
% This starts an instance with the default options
ldclient:start_instance("YOUR_SDK_KEY")

% You can also start a named instance
ldclient:start_instance("YOUR_SDK_KEY", my_instance)

Now you can check which flag variation a specific user should receive.

Flag = ldclient:variation(<<"YOUR_FLAG_KEY">>, #{key => <<"123">>}, false)

Supported features

This SDK supports the following features: