No results for ""
EXPAND ALL
  • Home
  • API docs

GIVE DOCS FEEDBACK

Using daemon mode

Read time: 5 minutes
Last edited: Dec 28, 2023

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.

Different SDKs have different names for daemon mode

When you configure the SDK so that it connects to the Relay Proxy, rather than to LaunchDarkly, for getting feature feature flag data, this mode has different names in different SDKs and SDK versions.


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 was previously known as the LaunchDarkly Daemon. Some SDKs, such as the C++ (server-side) SDK, refer to this mode as "lazy load," because flag data is loaded from the persistent store lazily, on demand as the SDK requests it. 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++ (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("sdk-key-123abc")
.DataStore(
Components.PersistentDataStore(
SomeDatabaseName.DataStore()
)
)
.DataSource(Components.ExternalUpdatesOnly)
.Build();

C++ (server-side)

Expand C++ (server-side) code sample

Use LazyLoadBuilder to set a persistent feature store:

using LazyLoad = server_side::config::builders::LazyLoadBuilder;
auto config_builder = server_side::ConfigBuilder(sdk_key);
auto some_source = YourDatabaseIntegration();
config_builder.DataSystem().Method(
LazyLoad().Source(some_source)
);
auto config = config_builder.Build();
if (!config) {
/* an error occurred, config is not valid */
}

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("sdk-key-123abc", #{
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 "sdk-key-123abc")
& 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

Specify a lazyLoad data source to set a persistent feature store:

local config = {
dataSystem = {
lazyLoad = {
source = makeYourSource()
}
}
}

To learn more about the configuration options, read clientInit.

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:

import * as ld from '@launchdarkly/node-server-sdk';
const store = SomeKindOfFeatureStore(storeOptions);
const options: ld.LDOptions = {
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("sdk-key-123abc",
[ '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
)