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

EDIT ON GITHUB

Erlang SDK reference

Read time: 1 minute
Last edited: Jul 28, 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:

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

Then add it to your app.src file:

1{applications,
2 [kernel,
3 stdlib,
4 ldclient
5]},

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

1defp deps do
2 [
3 {:ldclient, "~> 1.0.0", hex: :launchdarkly_server_sdk}
4 ]
5end

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.

Here is an example:

1% This starts an instance with the default options
2ldclient:start_instance("YOUR_SDK_KEY")
3
4% You can also start a named instance
5ldclient:start_instance("YOUR_SDK_KEY", my_instance)

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

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

Lastly, shut down the client when your application terminates. To learn more, read Shutting down.

Supported features

This SDK supports the following features: