Class PollingDataSourceBuilder
- java.lang.Object
-
- com.launchdarkly.sdk.android.integrations.PollingDataSourceBuilder
-
- All Implemented Interfaces:
ComponentConfigurer<DataSource>
public abstract class PollingDataSourceBuilder extends java.lang.Object implements ComponentConfigurer<DataSource>
Contains methods for configuring the polling data source.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 toLDConfig.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
Fields Modifier and Type Field Description protected int
backgroundPollIntervalMillis
static int
DEFAULT_POLL_INTERVAL_MILLIS
The default value forpollIntervalMillis(int)
: 5 minutes.protected int
pollIntervalMillis
-
Constructor Summary
Constructors Constructor Description PollingDataSourceBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PollingDataSourceBuilder
backgroundPollIntervalMillis(int backgroundPollIntervalMillis)
Sets the interval between feature flag updates when the application is running in the background.PollingDataSourceBuilder
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 Detail
-
DEFAULT_POLL_INTERVAL_MILLIS
public static final int DEFAULT_POLL_INTERVAL_MILLIS
The default value forpollIntervalMillis(int)
: 5 minutes.- See Also:
- Constant Field Values
-
backgroundPollIntervalMillis
protected int backgroundPollIntervalMillis
-
pollIntervalMillis
protected int pollIntervalMillis
-
-
Method Detail
-
backgroundPollIntervalMillis
public PollingDataSourceBuilder backgroundPollIntervalMillis(int 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(int)
-
pollIntervalMillis
public PollingDataSourceBuilder pollIntervalMillis(int 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:
backgroundPollIntervalMillis(int)
-
-