Class StreamingDataSourceBuilder

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

public abstract class StreamingDataSourceBuilder extends Object implements ComponentConfigurer<DataSource>
Contains methods for configuring the streaming data source.

By default, the SDK uses a streaming connection to receive feature flag data from LaunchDarkly. If you want to customize the behavior of the connection, create a builder with Components.streamingDataSource(), change its properties with the methods of this class, and pass it to LDConfig.Builder.dataSource(ComponentConfigurer):


     LDConfig config = new LDConfig.Builder()
         .dataSource(Components.streamingDataSource().initialReconnectDelayMillis(500))
         .build();
 

Note that this class is abstract; the actual implementation is created by calling Components.streamingDataSource().

Since:
3.3.0
  • Field Details

    • DEFAULT_INITIAL_RECONNECT_DELAY_MILLIS

      public static final int DEFAULT_INITIAL_RECONNECT_DELAY_MILLIS
      The default value for initialReconnectDelayMillis(int): 1000 milliseconds.
      See Also:
    • backgroundPollIntervalMillis

      protected int backgroundPollIntervalMillis
      Background polling interval in millis
    • initialReconnectDelayMillis

      protected int initialReconnectDelayMillis
      The initial reconnection delay in millis
    • streamEvenInBackground

      protected boolean streamEvenInBackground
      True if the data source will attempt to continue streaming when in the background
  • Constructor Details

    • StreamingDataSourceBuilder

      public StreamingDataSourceBuilder()
  • Method Details

    • backgroundPollIntervalMillis

      public StreamingDataSourceBuilder backgroundPollIntervalMillis(int backgroundPollIntervalMillis)
      Sets the interval between feature flag updates when the application is running in the background.

      Even when configured to use streaming, the SDK will switch to polling when in the background (unless LDConfig.Builder.disableBackgroundUpdating(boolean) is set). This property determines how often polling will happen.

      The default value is LDConfig.DEFAULT_BACKGROUND_POLL_INTERVAL_MILLIS; the minimum is LDConfig.MIN_BACKGROUND_POLL_INTERVAL_MILLIS.

      Parameters:
      backgroundPollIntervalMillis - the reconnect time base value in milliseconds
      Returns:
      the builder
    • initialReconnectDelayMillis

      public StreamingDataSourceBuilder initialReconnectDelayMillis(int initialReconnectDelayMillis)
      Sets the initial reconnect delay for the streaming connection.

      The streaming service uses a backoff algorithm (with jitter) every time the connection needs to be reestablished. The delay for the first reconnection will start near this value, and then increase exponentially for any subsequent connection failures.

      The default value is DEFAULT_INITIAL_RECONNECT_DELAY_MILLIS.

      Parameters:
      initialReconnectDelayMillis - the reconnect time base value in milliseconds
      Returns:
      the builder
    • streamEvenInBackground

      public StreamingDataSourceBuilder streamEvenInBackground(boolean streamEvenInBackground)
      Sets whether streaming should be used even if the application is in the background.

      By default, this option is false, meaning that if the application is in the background then the SDK will turn off the stream connection and use infrequent polling, until the application is in the foreground again.

      If you set this option to true, the SDK will continue to use the stream connection regardless of foreground/background state. Use this option with caution, since normally it is preferable to limit network usage by backgrounded applications.

      Parameters:
      streamEvenInBackground - true if streaming should be used even in the background
      Returns:
      the builder
      Since:
      4.1.0