public abstract class PollingDataSourceBuilder extends java.lang.Object implements UpdateProcessorFactory
Polling is not the default behavior; by default, the SDK uses a streaming connection to receive feature flag data from LaunchDarkly. In polling mode, the SDK instead makes a new HTTP request to LaunchDarkly at regular intervals. HTTP caching allows it to avoid redundantly downloading data if there have been no changes, but polling is still less efficient than streaming and should only be used on the advice of LaunchDarkly support.
To use polling mode, create a builder with Components.pollingDataSource()
,
change its properties with the methods of this class, and pass it to LDConfig.Builder.dataSource(UpdateProcessorFactory)
:
LDConfig config = new LDConfig.Builder()
.dataSource(Components.pollingDataSource().pollIntervalMillis(45000))
.build();
These properties will override any equivalent deprecated properties that were set with LDConfig.Builder
,
such as LDConfig.Builder.pollingIntervalMillis(long)
.
Note that this class is abstract; the actual implementation is created by calling Components.pollingDataSource()
.
Modifier and Type | Field and Description |
---|---|
protected java.net.URI |
baseURI |
static long |
DEFAULT_POLL_INTERVAL_MILLIS
The default and minimum value for
pollIntervalMillis(long) . |
protected long |
pollIntervalMillis |
Constructor and Description |
---|
PollingDataSourceBuilder() |
Modifier and Type | Method and Description |
---|---|
PollingDataSourceBuilder |
baseURI(java.net.URI baseURI)
Sets a custom base URI for the polling service.
|
PollingDataSourceBuilder |
pollIntervalMillis(long pollIntervalMillis)
Sets the interval at which the SDK will poll for feature flag updates.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createUpdateProcessor
public static final long DEFAULT_POLL_INTERVAL_MILLIS
pollIntervalMillis(long)
.protected java.net.URI baseURI
protected long pollIntervalMillis
public PollingDataSourceBuilder baseURI(java.net.URI baseURI)
You will only need to change this value in the following cases:
streamUri
to the base URI of the Relay Proxy instance.
baseURI
- the base URI of the polling service; null to use the defaultpublic PollingDataSourceBuilder pollIntervalMillis(long pollIntervalMillis)
The default and minimum value is DEFAULT_POLL_INTERVAL_MILLIS
. Values less than this will be
set to the default.
pollIntervalMillis
- the polling interval in milliseconds