C Server-Side SDK
LaunchDarkly SDK
LDTestData Struct Reference

An opaque TestData object. More...

#include <test_data.h>

Detailed Description

An opaque TestData object.

A mechanism for providing dynamically updatable feature flag state in a simplified form to an SDK client in test scenarios.

Unlike FileData, this mechanism does not use any external resources. It provides only the data that the application has put into it using LDTestDataUpdate.

struct LDTestData *td = LDTestDataInit();
{
struct LDFlagBuilder *flag = LDTestDataFlag(td, "flag-key-1");
LDTestDataUpdate(td, flag);
}
{
struct LDClient *client;
struct LDConfig *config = LDConfigNew("key"));
if(!(client = LDClientInit(config, 10))) {
LDConfigFree(config);
return;
}
}
{
struct LDFlagBuilder *flag = LDTestDataFlag(td, "flag-key-2");
LDFlagBuilderVariationForUserBoolean("some-user-key", LDBooleanTrue);
LDTestDataUpdate(td, flag);
}

The above example uses a simple boolean flag, but more complex configurations are possible using the methods of the LDFlagBuilder that is returned by LDTestDataFlag. LDFlagBuilder supports many of the ways a flag can be configured on the LaunchDarkly dashboard, but does not currently support

  1. rule operators other than "in" and "not in", or
  2. percentage rollouts.

If the same LDTestData instance is used to configure multiple LDClient instances, any changes made to the data will propagate to all of the LDClients.

Since
2.4.6
See also
TestData
FileData

The documentation for this struct was generated from the following file:
LDFlagBuilderVariationForUserBoolean
LDBoolean LDFlagBuilderVariationForUserBoolean(struct LDFlagBuilder *flagBuilder, const char *userKey, LDBoolean value)
Sets the flag to return the specified boolean variation for a specific user key when targeting is on.
LDConfigNew
struct LDConfig * LDConfigNew(const char *const key)
Creates a new default configuration. The configuration object is intended to be modified until it is ...
LDConfigFree
void LDConfigFree(struct LDConfig *const config)
Destroy a config not associated with a client instance.
LDTestDataCreateDataSource
struct LDDataSource * LDTestDataCreateDataSource(struct LDTestData *)
Create a LDDataSource instance to be used in a client config.
LDFlagBuilderFallthroughVariationBoolean
LDBoolean LDFlagBuilderFallthroughVariationBoolean(struct LDFlagBuilder *flagBuilder, LDBoolean value)
Specifies the fallthrough variation for a boolean flag.
LDFlagBuilder
A builder for feature flag configurations to be used with LDTestData.
Definition: test_data.h:66
LDConfig
An opaque config object.
LDFlagBuilderVariationForAllUsersBoolean
LDBoolean LDFlagBuilderVariationForAllUsersBoolean(struct LDFlagBuilder *flagBuilder, LDBoolean value)
Sets the flag to always return the specified boolean variation for all users.
LDTestDataFlag
struct LDFlagBuilder * LDTestDataFlag(struct LDTestData *testData, const char *key)
Creates or copies a LDFlagBuilder for building a test flag configuration.
LDConfigSetDataSource
void LDConfigSetDataSource(struct LDConfig *const config, struct LDDataSource *const dataSource)
Sets the implementation of the data source.
LDClient
An opaque client object.
LDTestDataUpdate
LDBoolean LDTestDataUpdate(struct LDTestData *testData, struct LDFlagBuilder *flagBuilder)
Updates the test data with the specified flag configuration.
LDClientInit
struct LDClient * LDClientInit(struct LDConfig *const config, const unsigned int maxwaitmilli)
Initialize a new client, and connect to LaunchDarkly. It's important to make LDClient a singleton....
LDTestData
An opaque TestData object.
LDTestDataInit
struct LDTestData * LDTestDataInit(void)
Creates a new instance of the LDTestData data source.