• Home
  • Integrations
  • SDKs
  • Guides
  • API docs
No results for ""
EXPAND ALL

EDIT ON GITHUB

Using daemon mode

Read time: 2 minutes
Last edited: May 20, 2022

Overview

Each SDK connects to several LaunchDarkly web services. These include services for getting feature flag data via streaming or polling, and a service for storing analytics events. By default, the SDK connects directly to LaunchDarkly for these services.

If you are using the Relay Proxy, you must configure the SDK so that it connects to the Relay Proxy for these services instead.

To use the Relay Proxy in daemon mode, you must first configure your server-side SDK to use a persistent data store. The SDK and the Relay Proxy must use the same data store. To configure your SDK to use a persistent data store, read Storing Data.

Then, you must configure your SDK to use daemon mode, as shown in the following examples. When you use the Relay Proxy in daemon mode, the SDK must not connect to any service for flag data. Some versions of the SDKs refer to this as using "external updates only." Other versions of the SDKs refer to this as "LDD mode," because the Relay Proxy is also known as the LaunchDarkly Daemon. In most SDKs, you then need to pass the configuration in as a parameter when you initialize the client. To learn more, read Configuration.

This feature is not available for client-side SDKs because in daemon mode, the SDK connects directly to the Relay Proxy's data store. This is not a supported behavior for client-side SDKs.

Server-side SDKs

This feature is available for the following server-side SDKs:

  • .NET (server-side)
  • C/C++ (server-side)
  • Erlang
  • Go
  • Haskell
  • Java
  • Lua
  • Node.js (server-side)
  • PHP
  • Python
  • Ruby

.NET (server-side)

Expand .NET (server-side) code sample

Use the DataStore builder method to set a persistent feature store. Then, use the DataSource builder method and Components.ExternalUpdatesOnly to configure daemon mode:

var config = Configuration.Builder("YOUR_SDK_KEY")
.DataStore(
Components.PersistentDataStore(
SomeDatabaseName.DataStore()
)
)
.DataSource(Components.ExternalUpdatesOnly)
.Build();

C/C++ (server-side)

Expand C/C++ (server-side) code sample

Use LDConfigSetFeatureStoreBackend to set a persistent feature store. Then, use LDConfigSetUseLDD to configure daemon mode:

struct LDConfig *config = LDConfigNew("YOUR_SDK_KEY");
struct LDStoreInterface *store = ConstructYourFeatureStoreInterface();
LDConfigSetFeatureStoreBackend(config, store);
LDConfigSetUseLDD(config, true);

Erlang

Expand Erlang code sample

Set the feature_store property to use a persistent data store. Then set the use_ldd property to configure daemon mode:

ldclient:start_instance("YOUR_SDK_KEY", #{
  use_ldd => true,
  feature_store => your_feature_store
})

Go

Expand Go code sample

Use PersistentDataStore() to set the persistent data store. Then, use ExternalUpdatesOnly() to configure daemon mode:

config := ld.Config{
DataStore: ldcomponents.PersistentDataStore(
examplepackage.DataStore().SomeStoreOptions(),
),
DataSource: ldcomponents.ExternalUpdatesOnly(),
}

Haskell

Expand Haskell code sample

Use configSetStoreBackend to set the persistent data store. Then, use configSetUseLdd to configure daemon mode:

{-# LANGUAGE OverloadedStrings #-}
import LaunchDarkly.Server.Config
import Data.Function ((&))
config :: Config
config = (makeConfig "YOUR_SDK_KEY")
& configSetUseLdd true
& configSetStoreBackend backend

Java

Expand Java code sample

Set the dataStore property to persistentDataStore() to use the persistent data store. Then, set the dataSource property to externalUpdatesOnly() to configure daemon mode:

LDConfig config = new LDConfig.Builder()
.dataStore(
Components.persistentDataStore(
SomeDatabaseName.DataStore(storeOptions)
)
)
.dataSource(Components.externalUpdatesOnly())
.build();

Lua

Expand Lua code sample

Set the featureStoreBackend property to use the persistent data store. Then, set the useLDD property to configure daemon mode:

local backend = makeYourBackendInterface()
local config = {
key = YOUR_SDK_KEY,
featureStoreBackend = backend,
useLDD = true
}

Node.js (server-side)

Expand Node.js (server-side) code sample

Set the featureStore property to use a persistent feature store. Then, set the useLdd property to configure daemon mode:

const store = SomeKindOfFeatureStore(storeOptions);
const options = {
featureStore: store,
useLdd: true,
};

PHP

Expand PHP code sample

Set the feature_requester property to use a persistent data store and daemon mode:

$client = new LaunchDarkly\LDClient("YOUR_SDK_KEY",
[ 'feature_requester' => LaunchDarkly\Integrations\NameOfDatabase::featureRequester() ]);

Python

Expand Python code sample

Set the feature_store property to use a persistent data store. Then, set the use_ldd property to configure daemon mode:

store = SomeKindOfFeatureStore(store_options)
config = Config(
feature_store=store,
use_ldd=True)

Ruby

Expand Ruby code sample

Set the feature_store property to use a persistent feature store. Then, set the use_ldd property to configure daemon mode:

store = SomeKindOfFeatureStore.new(storeOptions)
config = LaunchDarkly::Config.new(
feature_store: store
use_ldd: true
)