Class LDConfig.Builder
- java.lang.Object
-
- com.launchdarkly.sdk.server.LDConfig.Builder
-
- Enclosing class:
- LDConfig
public static class LDConfig.Builder extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Builder()
Creates a builder with all configuration parameters set to the default
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LDConfig.Builder
applicationInfo(ApplicationInfoBuilder applicationInfoBuilder)
Sets the SDK's application metadata, which may be used in LaunchDarkly analytics or other product features, but does not affect feature flag evaluations.LDConfig.Builder
bigSegments(ComponentConfigurer<BigSegmentsConfiguration> bigSegmentsConfigurer)
Sets the configuration of the SDK's Big Segments feature.LDConfig
build()
Builds the configuredLDConfig
object.LDConfig.Builder
dataSource(ComponentConfigurer<DataSource> dataSourceConfigurer)
Sets the implementation of the component that receives feature flag data from LaunchDarkly, using a factory object.LDConfig.Builder
dataStore(ComponentConfigurer<DataStore> dataStoreConfigurer)
Sets the implementation of the data store to be used for holding feature flags and related data received from LaunchDarkly, using a factory object.LDConfig.Builder
diagnosticOptOut(boolean diagnosticOptOut)
Set to true to opt out of sending diagnostics data.LDConfig.Builder
events(ComponentConfigurer<EventProcessor> eventsConfigurer)
Sets the implementation ofEventProcessor
to be used for processing analytics events.static LDConfig.Builder
fromConfig(LDConfig config)
Creates aLDConfig.Builder
from the providedLDConfig
LDConfig.Builder
hooks(HooksConfigurationBuilder hooksConfiguration)
Sets the SDK's hooks configuration, using a builder.LDConfig.Builder
http(ComponentConfigurer<HttpConfiguration> httpConfigurer)
Sets the SDK's networking configuration, using a configuration builder.LDConfig.Builder
logging(ComponentConfigurer<LoggingConfiguration> loggingConfigurer)
Sets the SDK's logging configuration, using a factory object.LDConfig.Builder
offline(boolean offline)
Set whether this client is offline.LDConfig.Builder
serviceEndpoints(ServiceEndpointsBuilder serviceEndpointsBuilder)
Sets the base service URIs used by SDK components.LDConfig.Builder
startWait(java.time.Duration startWait)
Set how long the constructor will block awaiting a successful connection to LaunchDarkly.LDConfig.Builder
threadPriority(int threadPriority)
Set the priority to use for all threads created by the SDK.LDConfig.Builder
wrapper(WrapperInfoBuilder wrapperBuilder)
Set the wrapper information.
-
-
-
Method Detail
-
fromConfig
public static LDConfig.Builder fromConfig(LDConfig config)
Creates aLDConfig.Builder
from the providedLDConfig
- Parameters:
config
- to be used to initialize the builder- Returns:
- the builder
-
applicationInfo
public LDConfig.Builder applicationInfo(ApplicationInfoBuilder applicationInfoBuilder)
Sets the SDK's application metadata, which may be used in LaunchDarkly analytics or other product features, but does not affect feature flag evaluations.This object is normally a configuration builder obtained from
Components.applicationInfo()
, which has methods for setting individual logging-related properties.- Parameters:
applicationInfoBuilder
- a configuration builder object returned byComponents.applicationInfo()
- Returns:
- the builder
- Since:
- 5.8.0
-
bigSegments
public LDConfig.Builder bigSegments(ComponentConfigurer<BigSegmentsConfiguration> bigSegmentsConfigurer)
Sets the configuration of the SDK's Big Segments feature.Big Segments are a specific type of user segments. For more information, read the LaunchDarkly documentation .
If you are using this feature, you will normally specify a database implementation that matches how the LaunchDarkly Relay Proxy is configured, since the Relay Proxy manages the Big Segment data.
By default, there is no implementation and Big Segments cannot be evaluated. In this case, any flag evaluation that references a Big Segment will behave as if no users are included in any Big Segments, and the
EvaluationReason
associated with any such flag evaluation will have aEvaluationReason.BigSegmentsStatus
ofEvaluationReason.BigSegmentsStatus.NOT_CONFIGURED
.// This example uses the Redis integration LDConfig config = LDConfig.builder() .bigSegments(Components.bigSegments(Redis.dataStore().prefix("app1")) .userCacheSize(2000)) .build();
- Parameters:
bigSegmentsConfigurer
- the Big Segments configuration builder- Returns:
- the builder
- Since:
- 5.7.0
- See Also:
Components.bigSegments(ComponentConfigurer)
-
dataSource
public LDConfig.Builder dataSource(ComponentConfigurer<DataSource> dataSourceConfigurer)
Sets the implementation of the component that receives feature flag data from LaunchDarkly, using a factory object. Depending on the implementation, the factory may be a builder that allows you to set other configuration options as well.The default is
Components.streamingDataSource()
. You may instead useComponents.pollingDataSource()
, or a test fixture such asFileData.dataSource()
. See those methods for details on how to configure them.- Parameters:
dataSourceConfigurer
- the data source configuration builder- Returns:
- the main configuration builder
- Since:
- 4.12.0
-
dataStore
public LDConfig.Builder dataStore(ComponentConfigurer<DataStore> dataStoreConfigurer)
Sets the implementation of the data store to be used for holding feature flags and related data received from LaunchDarkly, using a factory object. The default isComponents.inMemoryDataStore()
; for database integrations, useComponents.persistentDataStore(ComponentConfigurer)
.- Parameters:
dataStoreConfigurer
- the data store configuration builder- Returns:
- the main configuration builder
- Since:
- 4.12.0
-
diagnosticOptOut
public LDConfig.Builder diagnosticOptOut(boolean diagnosticOptOut)
Set to true to opt out of sending diagnostics data.Unless
diagnosticOptOut
is set to true, the client will send some diagnostics data to the LaunchDarkly servers in order to assist in the development of future SDK improvements. These diagnostics consist of an initial payload containing some details of SDK in use, the SDK's configuration, and the platform the SDK is being run on; as well as payloads sent periodically with information on irregular occurrences such as dropped events.- Parameters:
diagnosticOptOut
- true if you want to opt out of sending any diagnostics data- Returns:
- the builder
- Since:
- 4.12.0
- See Also:
EventProcessorBuilder.diagnosticRecordingInterval(Duration)
-
events
public LDConfig.Builder events(ComponentConfigurer<EventProcessor> eventsConfigurer)
Sets the implementation ofEventProcessor
to be used for processing analytics events.The default is
Components.sendEvents()
with no custom options. You may instead callComponents.sendEvents()
and then set custom options for event processing; or, disable events withComponents.noEvents()
; or, choose to use a custom implementation (for instance, a test fixture).- Parameters:
eventsConfigurer
- the events configuration builder- Returns:
- the main configuration builder
- Since:
- 4.12.0
- See Also:
Components.sendEvents()
,Components.noEvents()
-
hooks
public LDConfig.Builder hooks(HooksConfigurationBuilder hooksConfiguration)
Sets the SDK's hooks configuration, using a builder. This is normally a obtained fromComponents.hooks()
()}, which has methods for setting individual other hook related properties.- Parameters:
hooksConfiguration
- the hooks configuration builder- Returns:
- the main configuration builder
- See Also:
Components.hooks()
-
http
public LDConfig.Builder http(ComponentConfigurer<HttpConfiguration> httpConfigurer)
Sets the SDK's networking configuration, using a configuration builder. This builder is obtained fromComponents.httpConfiguration()
, and has methods for setting individual HTTP-related properties.- Parameters:
httpConfigurer
- the HTTP configuration builder- Returns:
- the main configuration builder
- Since:
- 4.13.0
- See Also:
Components.httpConfiguration()
-
logging
public LDConfig.Builder logging(ComponentConfigurer<LoggingConfiguration> loggingConfigurer)
Sets the SDK's logging configuration, using a factory object. This object is normally a configuration builder obtained fromComponents.logging()
, which has methods for setting individual logging-related properties.- Parameters:
loggingConfigurer
- the logging configuration builder- Returns:
- the main configuration builder
- Since:
- 5.0.0
- See Also:
Components.logging()
-
offline
public LDConfig.Builder offline(boolean offline)
Set whether this client is offline.In offline mode, the SDK will not make network connections to LaunchDarkly for any purpose. Feature flag data will only be available if it already exists in the data store, and analytics events will not be sent.
This is equivalent to calling
dataSource(Components.externalUpdatesOnly())
andevents(Components.noEvents())
. It overrides any other values you may have set fordataSource(ComponentConfigurer)
orevents(ComponentConfigurer)
.- Parameters:
offline
- when set to true no calls to LaunchDarkly will be made- Returns:
- the builder
-
serviceEndpoints
public LDConfig.Builder serviceEndpoints(ServiceEndpointsBuilder serviceEndpointsBuilder)
Sets the base service URIs used by SDK components.This object is normally a configuration builder obtained from
Components.serviceEndpoints()
, which has methods for setting each external endpoint to a custom URI.- Parameters:
serviceEndpointsBuilder
- a configuration builder object returned byComponents.applicationInfo()
- Returns:
- the builder
- Since:
- 5.9.0
-
startWait
public LDConfig.Builder startWait(java.time.Duration startWait)
Set how long the constructor will block awaiting a successful connection to LaunchDarkly. Setting this to a zero or negative duration will not block and cause the constructor to return immediately.The default is
LDConfig.DEFAULT_START_WAIT
.- Parameters:
startWait
- maximum time to wait; null to use the default- Returns:
- the builder
-
threadPriority
public LDConfig.Builder threadPriority(int threadPriority)
Set the priority to use for all threads created by the SDK.By default, the SDK's worker threads use
Thread.MIN_PRIORITY
so that they will yield to application threads if the JVM is busy. You may increase this if you want the SDK to be prioritized over some other low-priority tasks.Values outside the range of [
Thread.MIN_PRIORITY
,Thread.MAX_PRIORITY
] will be set to the minimum or maximum.- Parameters:
threadPriority
- the priority for SDK threads- Returns:
- the builder
- Since:
- 5.0.0
-
wrapper
public LDConfig.Builder wrapper(WrapperInfoBuilder wrapperBuilder)
Set the wrapper information.This is intended for use with wrapper SDKs from LaunchDarkly.
If the WrapperBuilder is set, then it will replace the wrapper information from the HttpPropertiesBuilder. Additionally, any wrapper SDK may overwrite any application developer provided wrapper information.
- Parameters:
wrapperBuilder
- the wrapper builder- Returns:
- the builder
- Since:
- 7.1.0
-
-