Class 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
Modifier and Type Method Description LDConfig
build()
Builds the configuredLDConfig
object.LDConfig.Builder
dataSource(DataSourceFactory factory)
Sets the implementation of the component that receives feature flag data from LaunchDarkly, using a factory object.LDConfig.Builder
dataStore(DataStoreFactory factory)
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(EventProcessorFactory factory)
Sets the implementation ofEventProcessor
to be used for processing analytics events.LDConfig.Builder
http(HttpConfigurationFactory factory)
Sets the SDK's networking configuration, using a factory object.LDConfig.Builder
logging(LoggingConfigurationFactory factory)
Sets the SDK's logging configuration, using a factory object.LDConfig.Builder
offline(boolean offline)
Set whether this client is offline.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.
-
Constructor Details
-
Builder
public Builder()Creates a builder with all configuration parameters set to the default
-
-
Method Details
-
dataSource
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:
factory
- the factory object- Returns:
- the builder
- Since:
- 4.12.0
-
dataStore
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(com.launchdarkly.sdk.server.interfaces.PersistentDataStoreFactory)
.- Parameters:
factory
- the factory object- Returns:
- the builder
- Since:
- 4.12.0
-
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
Sets the implementation ofEventProcessor
to be used for processing analytics events.The default is
Components.sendEvents()
, but you may choose to use a custom implementation (for instance, a test fixture), or disable events withComponents.noEvents()
.- Parameters:
factory
- a builder/factory object for event configuration- Returns:
- the builder
- Since:
- 4.12.0
-
http
Sets the SDK's networking configuration, using a factory object. This object is normally a configuration builder obtained fromComponents.httpConfiguration()
, which has methods for setting individual HTTP-related properties.- Parameters:
factory
- the factory object- Returns:
- the builder
- Since:
- 4.13.0
- See Also:
Components.httpConfiguration()
-
logging
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:
factory
- the factory object- Returns:
- the builder
- Since:
- 5.0.0
- See Also:
Components.logging()
-
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(DataSourceFactory)
orevents(EventProcessorFactory)
.- Parameters:
offline
- when set to true no calls to LaunchDarkly will be made- Returns:
- the builder
-
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. Default value: 5000- Parameters:
startWait
- maximum time to wait; null to use the default- Returns:
- the builder
-
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
-
build
Builds the configuredLDConfig
object.- Returns:
- the
LDConfig
configured by this builder
-