|
C++ Server-Side SDK
LaunchDarkly SDK
|
#include <launchdarkly/server_side/bindings/c/config/config.h>#include <launchdarkly/server_side/bindings/c/config/fdv2_builder/fdv2_builder.h>#include <launchdarkly/server_side/bindings/c/config/lazy_load_builder/lazy_load_builder.h>#include <launchdarkly/server_side/bindings/c/hook.h>#include <launchdarkly/bindings/c/config/logging_builder.h>#include <launchdarkly/bindings/c/export.h>#include <launchdarkly/bindings/c/status.h>#include <stdbool.h>#include <stddef.h>

Go to the source code of this file.
Functions | |
| LDServerConfigBuilder_New (char const *sdk_key) | |
| LDServerConfigBuilder_ServiceEndpoints_PollingBaseURL (LDServerConfigBuilder b, char const *url) | |
| LDServerConfigBuilder_ServiceEndpoints_StreamingBaseURL (LDServerConfigBuilder b, char const *url) | |
| LDServerConfigBuilder_ServiceEndpoints_EventsBaseURL (LDServerConfigBuilder b, char const *url) | |
| LDServerConfigBuilder_ServiceEndpoints_RelayProxyBaseURL (LDServerConfigBuilder b, char const *url) | |
| LDServerConfigBuilder_AppInfo_Identifier (LDServerConfigBuilder b, char const *app_id) | |
| LDServerConfigBuilder_AppInfo_Version (LDServerConfigBuilder b, char const *app_version) | |
| LDServerConfigBuilder_Offline (LDServerConfigBuilder b, bool offline) | |
| LDServerConfigBuilder_Events_Enabled (LDServerConfigBuilder b, bool enabled) | |
| LDServerConfigBuilder_Events_ContextKeysCapacity (LDServerConfigBuilder b, size_t context_keys_capacity) | |
| LDServerConfigBuilder_Events_Capacity (LDServerConfigBuilder b, size_t capacity) | |
| LDServerConfigBuilder_Events_FlushIntervalMs (LDServerConfigBuilder b, unsigned int milliseconds) | |
| LDServerConfigBuilder_Events_AllAttributesPrivate (LDServerConfigBuilder b, bool all_attributes_private) | |
| LDServerConfigBuilder_Events_PrivateAttribute (LDServerConfigBuilder b, char const *attribute_reference) | |
| LDServerConfigBuilder_DataSystem_BackgroundSync_Streaming (LDServerConfigBuilder b, LDServerDataSourceStreamBuilder stream_builder) | |
| LDServerConfigBuilder_DataSystem_BackgroundSync_Polling (LDServerConfigBuilder b, LDServerDataSourcePollBuilder poll_builder) | |
| LDServerConfigBuilder_DataSystem_LazyLoad (LDServerConfigBuilder b, LDServerLazyLoadBuilder lazy_load_builder) | |
| LDServerConfigBuilder_DataSystem_FDv2 (LDServerConfigBuilder b, LDServerFDv2Builder fdv2_builder) | |
| LDServerConfigBuilder_DataSystem_Enabled (LDServerConfigBuilder b, bool enabled) | |
| LDServerDataSourceStreamBuilder_New () | |
| LDServerDataSourceStreamBuilder_InitialReconnectDelayMs (LDServerDataSourceStreamBuilder b, unsigned int milliseconds) | |
| LDServerDataSourceStreamBuilder_Filter (LDServerDataSourceStreamBuilder b, char const *filter_key) | |
| LDServerDataSourceStreamBuilder_Free (LDServerDataSourceStreamBuilder b) | |
| LDServerDataSourcePollBuilder_New () | |
| LDServerDataSourcePollBuilder_IntervalS (LDServerDataSourcePollBuilder b, unsigned int seconds) | |
| LDServerDataSourcePollBuilder_Filter (LDServerDataSourcePollBuilder b, char const *filter_key) | |
| LDServerDataSourcePollBuilder_Free (LDServerDataSourcePollBuilder b) | |
| LDServerConfigBuilder_HttpProperties_WrapperName (LDServerConfigBuilder b, char const *wrapper_name) | |
| LDServerConfigBuilder_HttpProperties_WrapperVersion (LDServerConfigBuilder b, char const *wrapper_version) | |
| LDServerConfigBuilder_HttpProperties_Header (LDServerConfigBuilder b, char const *key, char const *value) | |
| LDServerConfigBuilder_HttpProperties_Tls (LDServerConfigBuilder b, LDServerHttpPropertiesTlsBuilder tls_builder) | |
| LDServerHttpPropertiesTlsBuilder_New (void) | |
| LDServerHttpPropertiesTlsBuilder_Free (LDServerHttpPropertiesTlsBuilder b) | |
| LDServerHttpPropertiesTlsBuilder_SkipVerifyPeer (LDServerHttpPropertiesTlsBuilder b, bool skip_verify_peer) | |
| LDServerHttpPropertiesTlsBuilder_CustomCAFile (LDServerHttpPropertiesTlsBuilder b, char const *custom_ca_file) | |
| LDServerConfigBuilder_HttpProperties_Proxy (LDServerConfigBuilder b, char const *proxy_url) | |
| LDServerConfigBuilder_Logging_Disable (LDServerConfigBuilder b) | |
| LDServerConfigBuilder_Logging_Basic (LDServerConfigBuilder b, LDLoggingBasicBuilder basic_builder) | |
| LDServerConfigBuilder_Logging_Custom (LDServerConfigBuilder b, LDLoggingCustomBuilder custom_builder) | |
| LDServerConfigBuilder_Hooks (LDServerConfigBuilder builder, struct LDServerSDKHook hook) | |
| LDServerConfigBuilder_Build (LDServerConfigBuilder builder, LDServerConfig *out_config) | |
| LDServerConfigBuilder_Free (LDServerConfigBuilder builder) | |
| LDServerConfigBuilder_AppInfo_Identifier | ( | LDServerConfigBuilder | b, |
| char const * | app_id | ||
| ) |
Sets an identifier for the application.
| b | Server config builder. Must not be NULL. |
| app_id | Non-empty string. Must be <= 64 chars. Must be alphanumeric, '-', '.', or '_'. Must not be NULL. |
| LDServerConfigBuilder_AppInfo_Version | ( | LDServerConfigBuilder | b, |
| char const * | app_version | ||
| ) |
Sets a version for the application.
| b | Server config builder. Must not be NULL. |
| app_version | Non-empty string. Must be <= 64 chars. Must be alphanumeric, '-', '.', or '_'. Must not be NULL. |
| LDServerConfigBuilder_Build | ( | LDServerConfigBuilder | builder, |
| LDServerConfig * | out_config | ||
| ) |
Creates an LDClientConfig. The builder is automatically freed.
WARNING: Do not call any other LDServerConfigBuilder function on the provided LDServerConfigBuilder after calling this function. It is undefined behavior.
On success, the config will be stored in out_config; otherwise, out_config will be set to NULL and the returned LDStatus will indicate the error.
| builder | Builder to consume. Must not be NULL. |
| out_config | Pointer to where the built config will be stored. Must not be NULL. |
| LDServerConfigBuilder_DataSystem_BackgroundSync_Polling | ( | LDServerConfigBuilder | b, |
| LDServerDataSourcePollBuilder | poll_builder | ||
| ) |
Configures the Background Sync data system with a Polling synchronizer. The builder is automatically freed.
WARNING: Do not call any other LDServerDataSourcePollBuilder function on the provided LDServerDataSourcePollBuilder after calling this function. It is undefined behavior.
This synchronizer may be chosen to override the default Streaming mode.
In this mode, the SDK makes periodic network requests to LaunchDarkly. Between requests, flag data may be stale to some degree. This mode may be advantageous if a streaming connection cannot be maintained.
| b | Server config builder. Must not be NULL. |
| poll_builder | The polling builder. The builder is consumed; do not free it. Must not be NULL. |
| LDServerConfigBuilder_DataSystem_BackgroundSync_Streaming | ( | LDServerConfigBuilder | b, |
| LDServerDataSourceStreamBuilder | stream_builder | ||
| ) |
Configures the Background Sync data system with a Streaming synchronizer. The builder is automatically freed.
WARNING: Do not call any other LDServerDataSourceStreamBuilder function on the provided LDServerDataSourceStreamBuilder after calling this function. It is undefined behavior.
This is the default data system configuration for the SDK.
In this mode, the SDK maintains a persistent, streaming data connection with LaunchDarkly. The application is able to evaluate using the most recent flag configurations, since any changes are streamed from LaunchDarkly in the background.
| b | Server config builder. Must not be NULL. |
| stream_builder | The streaming builder. The builder is consumed; do not free it. Must not be NULL. |
| LDServerConfigBuilder_DataSystem_Enabled | ( | LDServerConfigBuilder | b, |
| bool | enabled | ||
| ) |
Specify if the SDK's data system should be enabled or not.
If disabled, the SDK won't be able to obtain flag configuration and will instead serve application-provided default values.
| b | Server config builder. Must not be NULL. |
| enabled | True to enable the data system, false to disable it. |
| LDServerConfigBuilder_DataSystem_FDv2 | ( | LDServerConfigBuilder | b, |
| LDServerFDv2Builder | fdv2_builder | ||
| ) |
Configures the FDv2 data system. The builder is automatically consumed.
This method is mutually exclusive with the BackgroundSync_Streaming, BackgroundSync_Polling, and LazyLoad builders.
WARNING: Do not call any other LDServerFDv2Builder function on the provided builder after calling this function. It is undefined behavior.
FDv2 receives flag delivery updates over the changeset-based protocol with built-in fallback and recovery semantics. An optional FDv1 fallback may be configured on the FDv2 builder for service-directed protocol fallback.
| b | Server config builder. Must not be NULL. |
| fdv2_builder | The FDv2 builder. The builder is consumed; do not free it. Must not be NULL. |
| LDServerConfigBuilder_DataSystem_LazyLoad | ( | LDServerConfigBuilder | b, |
| LDServerLazyLoadBuilder | lazy_load_builder | ||
| ) |
Configures the Lazy Load data system. The builder is automatically consumed.
This method is mutually exclusive with the BackgroundSync_Polling and BackgroundSync_Streaming builders.
WARNING: Do not call any other LDServerLazyLoadBuilder function on the provided LDServerLazyLoadBuilder after calling this function. It is undefined behavior.
In this mode the SDK will query a data source on-demand as required, with an in-memory cache to reduce the number of queries.
| b | Server config builder. Must not be NULL. |
| lazy_load_builder | The lazy load builder. The builder is consumed; do not free it. Must not be NULL. |
| LDServerConfigBuilder_Events_AllAttributesPrivate | ( | LDServerConfigBuilder | b, |
| bool | all_attributes_private | ||
| ) |
Attribute privacy indicates whether or not attributes should be retained by LaunchDarkly after being sent upon initialization, and if attributes should later be sent in events.
Attribute privacy may be specified in 3 ways:
(1) To specify that all attributes should be considered private - not just those designated private on a per-context basis - call this method with true as the parameter.
(2) To specify that a specific set of attributes should be considered private - in addition to those designated private on a per-context basis
(3) To specify private attributes on a per-context basis, it is not necessary to call either of these methods, as the default behavior is to treat all attributes as non-private unless otherwise specified.
| b | Server config builder. Must not be NULL. |
| all_attributes_private | True for behavior of (1), false for default behavior of (2) or (3). |
| LDServerConfigBuilder_Events_Capacity | ( | LDServerConfigBuilder | b, |
| size_t | capacity | ||
| ) |
Sets the capacity of the event processor. When more events are generated within the processor's flush interval than this value, events will be dropped.
| b | Server config builder. Must not be NULL. |
| capacity | Event queue capacity. |
| LDServerConfigBuilder_Events_ContextKeysCapacity | ( | LDServerConfigBuilder | b, |
| size_t | context_keys_capacity | ||
| ) |
Specifies the number of unique context keys that can be remembered by the index event generation logic before needing to evict keys from memory in LRU order.
After reaching capacity, it's possible that a previously-indexed context may cause generation of a redundant index event.
| b | Server config builder. Must not be NULL. |
| context_keys_capacity | Maximum unique context keys to remember. The default is 1000. |
| LDServerConfigBuilder_Events_Enabled | ( | LDServerConfigBuilder | b, |
| bool | enabled | ||
| ) |
Specify if event-sending should be enabled or not. By default, events are enabled.
| b | Server config builder. Must not be NULL. |
| enabled | True to enable event-sending. |
| LDServerConfigBuilder_Events_FlushIntervalMs | ( | LDServerConfigBuilder | b, |
| unsigned int | milliseconds | ||
| ) |
Sets the flush interval of the event processor. The processor queues outgoing events based on the capacity parameter; these events are then delivered based on the flush interval.
| b | Server config builder. Must not be NULL. |
| milliseconds | Interval between automatic flushes. |
| LDServerConfigBuilder_Events_PrivateAttribute | ( | LDServerConfigBuilder | b, |
| char const * | attribute_reference | ||
| ) |
Specifies a single private attribute. May be called multiple times with additional private attributes.
| b | Server config builder. Must not be NULL. |
| attribute_reference | Attribute to mark private. |
| LDServerConfigBuilder_Free | ( | LDServerConfigBuilder | builder | ) |
Frees the builder; only necessary if not calling Build.
| builder | Builder to free. |
| LDServerConfigBuilder_Hooks | ( | LDServerConfigBuilder | builder, |
| struct LDServerSDKHook | hook | ||
| ) |
Registers a hook with the SDK.
Hooks allow you to instrument SDK behavior for logging, analytics, or distributed tracing (e.g. OpenTelemetry).
Multiple hooks can be registered. They execute in the order registered.
LIFETIME: The hook struct is copied during this call. The Name string must remain valid until LDServerConfigBuilder_Build() is called. UserData and function pointers must remain valid for the SDK lifetime.
| builder | Configuration builder. Must not be NULL. |
| hook | Hook to register. The struct is copied. Must not be NULL. |
| LDServerConfigBuilder_HttpProperties_Header | ( | LDServerConfigBuilder | b, |
| char const * | key, | ||
| char const * | value | ||
| ) |
Set a custom header value. May be called more than once with additional headers.
| b | Server config builder. Must not be NULL. |
| key | Name of the header. Must not be NULL. |
| value | Value of the header. Must not be NULL. |
| LDServerConfigBuilder_HttpProperties_Proxy | ( | LDServerConfigBuilder | b, |
| char const * | proxy_url | ||
| ) |
Sets proxy configuration for HTTP requests.
When using CURL networking (LD_CURL_NETWORKING=ON), this controls proxy behavior. The proxy URL takes precedence over environment variables (ALL_PROXY, HTTP_PROXY, HTTPS_PROXY).
Supported proxy types (when CURL networking is enabled):
Passing an empty string explicitly disables proxy (overrides environment variables).
When CURL networking is disabled, attempting to configure a non-empty proxy will cause the Build function to fail.
| b | Server config builder. Must not be NULL. |
| proxy_url | Proxy URL or empty string to disable. Must not be NULL. |
| LDServerConfigBuilder_HttpProperties_Tls | ( | LDServerConfigBuilder | b, |
| LDServerHttpPropertiesTlsBuilder | tls_builder | ||
| ) |
Sets the TLS options builder. The builder is automatically freed.
WARNING: Do not call any other LDServerHttpPropertiesTlsBuilder function on the provided LDServerHttpPropertiesTlsBuilder after calling this function. It is undefined behavior.
| b | Server config builder. Must not be NULL. |
| tls_builder | The TLS options builder. Must not be NULL. |
| LDServerConfigBuilder_HttpProperties_WrapperName | ( | LDServerConfigBuilder | b, |
| char const * | wrapper_name | ||
| ) |
This should be used for wrapper SDKs to set the wrapper name.
Wrapper information will be included in request headers.
| b | Server config builder. Must not be NULL. |
| wrapper_name | Name of the wrapper. |
| LDServerConfigBuilder_HttpProperties_WrapperVersion | ( | LDServerConfigBuilder | b, |
| char const * | wrapper_version | ||
| ) |
This should be used for wrapper SDKs to set the wrapper version.
Wrapper information will be included in request headers.
| b | Server config builder. Must not be NULL. |
| wrapper_version | Version of the wrapper. |
| LDServerConfigBuilder_Logging_Basic | ( | LDServerConfigBuilder | b, |
| LDLoggingBasicBuilder | basic_builder | ||
| ) |
Configures the SDK with basic logging. The builder is automatically freed.
WARNING: Do not call any other LDLoggingBasicBuilder function on the provided LDLoggingBasicBuilder after calling this function. It is undefined behavior.
| b | Server config builder. Must not be NULL. |
| basic_builder | The basic logging builder. Must not be NULL. |
| LDServerConfigBuilder_Logging_Custom | ( | LDServerConfigBuilder | b, |
| LDLoggingCustomBuilder | custom_builder | ||
| ) |
Configures the SDK with custom logging.
| b | Server config builder. Must not be NULL. |
| custom_builder | The custom logging builder. Must not be NULL. |
| LDServerConfigBuilder_Logging_Disable | ( | LDServerConfigBuilder | b | ) |
Disables the default SDK logging.
| b | Server config builder. Must not be NULL. |
| LDServerConfigBuilder_New | ( | char const * | sdk_key | ) |
Constructs a client-side config builder.
| LDServerConfigBuilder_Offline | ( | LDServerConfigBuilder | b, |
| bool | offline | ||
| ) |
If true, equivalent to setting LDServerConfigBuilder_Events_Enabled(false) and LDServerConfigBuilder_DataSystem_Enabled(false).
The effect is that all evaluations will return application-provided default values, and no network calls will be made.
This overrides specific configuration of events and/or data system, if present.
| b | Server config builder. Must not be NULL. |
| offline | True if offline. |
| LDServerConfigBuilder_ServiceEndpoints_EventsBaseURL | ( | LDServerConfigBuilder | b, |
| char const * | url | ||
| ) |
Sets a custom URL for the events service.
| b | Server config builder. Must not be NULL. |
| url | Target URL. Must not be NULL. |
| LDServerConfigBuilder_ServiceEndpoints_PollingBaseURL | ( | LDServerConfigBuilder | b, |
| char const * | url | ||
| ) |
Sets a custom URL for the polling service.
| b | Server config builder. Must not be NULL. |
| url | Target URL. Must not be NULL. |
| LDServerConfigBuilder_ServiceEndpoints_RelayProxyBaseURL | ( | LDServerConfigBuilder | b, |
| char const * | url | ||
| ) |
Sets a custom URL for a Relay Proxy instance. The streaming, polling, and events URLs are set automatically.
| b | Server config builder. Must not be NULL. |
| url | Target URL. Must not be NULL. |
| LDServerConfigBuilder_ServiceEndpoints_StreamingBaseURL | ( | LDServerConfigBuilder | b, |
| char const * | url | ||
| ) |
Sets a custom URL for the streaming service.
| b | Server config builder. Must not be NULL. |
| url | Target URL. Must not be NULL. |
| LDServerDataSourcePollBuilder_Filter | ( | LDServerDataSourcePollBuilder | b, |
| char const * | filter_key | ||
| ) |
Sets the filter key for the polling connection.
By default, the SDK is able to evaluate all flags in an environment.
If this is undesirable - for example, because the environment contains thousands of flags, but this application only needs to evaluate a smaller, known subset - then a filter may be setup in LaunchDarkly, and the filter's key specified here.
Evaluations for flags that aren't part of the filtered environment will return default values.
| b | Polling method builder. Must not be NULL. |
| filter_key | The filter key. Must not be NULL. If the key is malformed or nonexistent, then a full LaunchDarkly environment will be fetched. In the case of a malformed key, the SDK will additionally log a runtime error. |
| LDServerDataSourcePollBuilder_Free | ( | LDServerDataSourcePollBuilder | b | ) |
Frees a Polling method builder. Do not call if the builder was consumed by the config builder.
| b | Builder to free. |
| LDServerDataSourcePollBuilder_IntervalS | ( | LDServerDataSourcePollBuilder | b, |
| unsigned int | seconds | ||
| ) |
Sets the interval at which the SDK will poll for feature flag updates.
| b | Polling method builder. Must not be NULL. |
| seconds | Polling interval in seconds. |
| LDServerDataSourcePollBuilder_New | ( | ) |
Creates a new DataSource builder for the Polling method.
If not passed into the config builder, must be manually freed with LDServerDataSourcePollBuilder_Free.
| LDServerDataSourceStreamBuilder_Filter | ( | LDServerDataSourceStreamBuilder | b, |
| char const * | filter_key | ||
| ) |
Sets the filter key for the streaming connection.
By default, the SDK is able to evaluate all flags in an environment.
If this is undesirable - for example, because the environment contains thousands of flags, but this application only needs to evaluate a smaller, known subset - then a filter may be setup in LaunchDarkly, and the filter's key specified here.
Evaluations for flags that aren't part of the filtered environment will return default values.
| b | Streaming method builder. Must not be NULL. |
| filter_key | The filter key. Must not be NULL. If the key is malformed or nonexistent, then a full LaunchDarkly environment will be fetched. In the case of a malformed key, the SDK will additionally log a runtime error. |
| LDServerDataSourceStreamBuilder_Free | ( | LDServerDataSourceStreamBuilder | b | ) |
Frees a Streaming method builder. Do not call if the builder was consumed by the config builder.
| b | Builder to free. |
| LDServerDataSourceStreamBuilder_InitialReconnectDelayMs | ( | LDServerDataSourceStreamBuilder | b, |
| unsigned int | milliseconds | ||
| ) |
Sets the initial reconnect delay for the streaming connection.
The streaming service uses a backoff algorithm (with jitter) every time the connection needs to be reestablished.The delay for the first reconnection will start near this value, and then increase exponentially for any subsequent connection failures.
| b | Streaming method builder. Must not be NULL. |
| milliseconds | Initial delay for a reconnection attempt. |
| LDServerDataSourceStreamBuilder_New | ( | ) |
Creates a new DataSource builder for the Streaming method.
If not passed into the config builder, must be manually freed with LDServerDataSourceStreamBuilder_Free.
| LDServerHttpPropertiesTlsBuilder_CustomCAFile | ( | LDServerHttpPropertiesTlsBuilder | b, |
| char const * | custom_ca_file | ||
| ) |
Configures TLS peer certificate verification to use a custom CA file.
The parameter is a filepath pointing to a bundle of one or more PEM-encoded x509 certificates comprising the root of trust for the SDK's outbound connections.
By default, the SDK uses the system's CA bundle. Passing the empty string will unset any previously set path and revert to the system's CA bundle.
| b | Server config builder. Must not be NULL. |
| custom_ca_file | Filepath of the custom CA bundle, or empty string. Must not be NULL. |
| LDServerHttpPropertiesTlsBuilder_Free | ( | LDServerHttpPropertiesTlsBuilder | b | ) |
Frees a TLS options builder. Do not call if the builder was consumed by the HttpProperties builder.
| b | Builder to free. |
| LDServerHttpPropertiesTlsBuilder_New | ( | void | ) |
Creates a new TLS options builder for the HttpProperties builder.
If not passed into the HttpProperties builder, must be manually freed with LDServerHttpPropertiesTlsBuilder_Free.
| LDServerHttpPropertiesTlsBuilder_SkipVerifyPeer | ( | LDServerHttpPropertiesTlsBuilder | b, |
| bool | skip_verify_peer | ||
| ) |
Configures TLS peer certificate verification. Peer verification is enabled by default.
Disabling peer verification is not recommended unless a specific use-case calls for it.
| b | Server config builder. Must not be NULL. |
| skip_verify_peer | True to skip verification. |