Class PollingDataSourceBuilder

java.lang.Object
com.launchdarkly.sdk.android.integrations.PollingDataSourceBuilder
All Implemented Interfaces:
ComponentConfigurer<DataSource>

public abstract class PollingDataSourceBuilder extends 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 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 Details

    • DEFAULT_POLL_INTERVAL_MILLIS

      public static final int DEFAULT_POLL_INTERVAL_MILLIS
      The default value for pollIntervalMillis(int): 5 minutes.
      See Also:
    • backgroundPollIntervalMillis

      protected int backgroundPollIntervalMillis
      The background polling interval in millis
    • pollIntervalMillis

      protected int pollIntervalMillis
      The foreground polling interval in millis
    • oneShot

      protected boolean oneShot
      If true, the polling data source will make at most one poll attempt to get feature flag updates. The one shot poll may be blocked by rate limiting logic and will not be retried if that occurs.
  • Constructor Details

    • PollingDataSourceBuilder

      public PollingDataSourceBuilder()
  • Method Details