Skip to main content

Documentation Index

Fetch the complete documentation index at: https://launchdarkly-preview.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

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.
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)

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();
If you are using the newer DataSystem configuration added in .NET SDK 8.11+, use the DataSystem builder with Components.DataSystem().Daemon() to configure daemon mode:
      var config = Configuration.Builder("YOUR_SDK_KEY")
          .DataSystem(
              Components.DataSystem().Daemon(
                  Components.PersistentDataStore(Redis.DataStore())
              )
          )
          .Build();

C++ (server-side)

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

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

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

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

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();
If you are using the newer DataSystem configuration added in Java SDK 7.11+, use the dataSystem builder with Components.dataSystem().daemon() to configure daemon mode:
      import com.launchdarkly.sdk.server.*;

      LDConfig config = new LDConfig.Builder()
          .dataSystem(
              Components.dataSystem().daemon(
                  Components.persistentDataStore(Redis.dataStore())
              )
          )
          .build();

      LDClient client = new LDClient("YOUR_SDK_KEY", config);

Lua

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)

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

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

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

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
      )
If you are using the newer DataSystem configuration added in Ruby SDK 8.12.0+, use the data_system_config option with LaunchDarkly::DataSystem.daemon() to configure daemon mode:
      require 'ldclient-rb'

      store = SomeKindOfFeatureStore.new(storeOptions)

      config = LaunchDarkly::Config.new(
        data_system_config: LaunchDarkly::DataSystem.daemon(store).build
      )

      client = LaunchDarkly::LDClient.new("YOUR_SDK_KEY", config)

Rust

Using the PersistentDataStoreBuilder, provide a persistent store factory.Enable daemon mode by calling daemon_mode(true) on the ConfigBuilder:
      use launchdarkly_server_sdk::{ConfigBuilder, PersistentDataStoreBuilder};


      let persistent_store_factory = SomeKindOfFeatureStore.new(storeOptions)
      let persistent_data_store_builder = PersistentDataStoreBuilder::new(Arc::new(persistent_store_factory));

      let config = ConfigBuilder::new("sdk-key")
                  .daemon_mode(true)
                  .data_store(&builder)
                  .build()
                  .expect("config should build");