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
This topic explains how to use the SDK Consul integration as a persistent feature store.How the SDKs store data in Consul
The Consul integrations for all LaunchDarkly server-side SDKs use the same conventions, so that SDK instances and Relay Proxy instances sharing a single Consul store can interoperate correctly. The storage schema is as follows:- There is always a “prefix” string that provides a namespace for the overall data set. If you do not specify a prefix in your configuration, it is
launchdarkly. - For each data item that the SDK can store, such as a feature flag, there is a Consul key-value pair where the key is
PREFIX/TYPE/KEY.PREFIXis the configured prefix string.TYPEdenotes the type of data such asfeaturesandsegments.KEYis the unique key of the item. For example, aKEYcould be the flag key for a feature flag. The value is a serialized representation of that item, in a format that is determined by the SDK. - An additional key,
PREFIX/$inited, is created with an arbitrary value when the SDK stores a full set of feature flag data. This allows a new SDK instance to check whether there is already a valid data set that was stored earlier. - The SDK may use additional keys starting with the
PREFIXstring, so you should not assume that theTYPEvalues mentioned above and$initedare the only possible keys. But the SDK never adds, modifies, or removes any keys in Consul other than ones starting with thePREFIX, so it is safe to share a Consul instance that is also being used for other purposes.
Server-side SDKs
In the following examples, the Consul feature store is set to use a host address ofmy-consul:8100, a prefix string of "my-key-prefix", and a cache TTL of 30 seconds.
This feature is available in the following server-side SDKs:
.NET (server-side)
Expand .NET (server-side) code sample
Expand .NET (server-side) code sample
If using the .NET SDK, you must install the additional package To learn more, read
LaunchDarkly.ServerSdk.Consul.dotnet-server-sdk-consul.Go
Expand Go code sample
Expand Go code sample
The Go integration is in To learn more, read
github.com/launchdarkly/go-server-sdk-consul for version 5.0.0 or higher of the SDK. In versions 4.5.0 and higher, but below 5.0.0, it is in the main SDK distribution as the subpackage ldconsul.go-server-sdk-consul.Java
Expand Java code sample
Expand Java code sample
If using the Java SDK, you must install the additional package To learn more, read
com.launchdarkly.launchdarkly-java-server-sdk-consul-store.java-server-sdk-consul.Node.js (server-side)
Expand Node.js (server-side) code sample
Expand Node.js (server-side) code sample
If using the Node.js SDK you must install the additional package
launchdarkly-node-server-consul.The Node.js (server-side) SDK v8.0 does not include Consul support. If you have questions or want to request this, start a Support ticket.
PHP
Expand PHP code sample
Expand PHP code sample
In version 4.0 and higher of the PHP SDK, you must add the package To learn more, read
launchdarkly/server-sdk-consul to your application’s Composer dependencies to use the Consul integration.In versions 3.x and earlier, the Consul integration is built into the main SDK package, but you must add a package dependency for aws/sensiolabs/consul-php-sdk.To use the Consul integration:php-server-sdk-consul.Python
Expand Python code sample
Expand Python code sample
The Python integration is part of the main SDK distribution as of version 6.8.1, but you must also install the package
python-consul. Python 3.3 and 3.4 are not supported.Ruby
Expand Ruby code sample
Expand Ruby code sample
The Ruby integration is part of the main SDK distribution as of version 5.1.1, but you must also install the gem
diplomat.