Class PollingDataSourceBuilder
- All Implemented Interfaces:
ComponentConfigurer<DataSource>
Polling is not the default behavior; by default, the SDK uses a streaming connection to receive feature flag data from LaunchDarkly whenever the application is in the foreground. 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()
, set any custom
options if desired with the methods of this class, and pass it to
LDConfig.Builder.dataSource(ComponentConfigurer)
:
LDConfig config = new LDConfig.Builder()
.dataSource(Components.pollingDataSource().pollIntervalMillis(30000))
.build();
Note that this class is abstract; the actual implementation is created by calling
Components.pollingDataSource()
.
- Since:
- 3.3.0
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
The background polling interval in millisstatic final int
The default value forpollIntervalMillis(int)
: 5 minutes.protected int
The foreground polling interval in millis -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbackgroundPollIntervalMillis
(int backgroundPollIntervalMillis) Sets the interval between feature flag updates when the application is running in the background.pollIntervalMillis
(int pollIntervalMillis) Sets the interval between feature flag updates when the application is running in the foreground.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.launchdarkly.sdk.android.subsystems.ComponentConfigurer
build
-
Field Details
-
DEFAULT_POLL_INTERVAL_MILLIS
public static final int DEFAULT_POLL_INTERVAL_MILLISThe default value forpollIntervalMillis(int)
: 5 minutes.- See Also:
-
backgroundPollIntervalMillis
protected int backgroundPollIntervalMillisThe background polling interval in millis -
pollIntervalMillis
protected int pollIntervalMillisThe foreground polling interval in millis
-
-
Constructor Details
-
PollingDataSourceBuilder
public PollingDataSourceBuilder()
-
-
Method Details
-
backgroundPollIntervalMillis
Sets the interval between feature flag updates when the application is running in the background.This is normally a longer interval than the foreground polling interval (
pollIntervalMillis(int)
). It is ignored if you have turned off background polling entirely by settingLDConfig.Builder.disableBackgroundUpdating(boolean)
.The default value is
LDConfig.DEFAULT_BACKGROUND_POLL_INTERVAL_MILLIS
; the minimum isLDConfig.MIN_BACKGROUND_POLL_INTERVAL_MILLIS
.- Parameters:
backgroundPollIntervalMillis
- the background polling interval in milliseconds- Returns:
- the builder
- See Also:
-
pollIntervalMillis
Sets the interval between feature flag updates when the application is running in the foreground.The default value is
DEFAULT_POLL_INTERVAL_MILLIS
. That is also the minimum value.- Parameters:
pollIntervalMillis
- the reconnect time base value in milliseconds- Returns:
- the builder
- See Also:
-