Class StreamingDataSourceBuilder
- java.lang.Object
-
- com.launchdarkly.sdk.android.integrations.StreamingDataSourceBuilder
-
- All Implemented Interfaces:
ComponentConfigurer<DataSource>
public abstract class StreamingDataSourceBuilder extends java.lang.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 toLDConfig.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 Summary
Fields Modifier and Type Field Description protected int
backgroundPollIntervalMillis
static int
DEFAULT_INITIAL_RECONNECT_DELAY_MILLIS
The default value forinitialReconnectDelayMillis(int)
: 1000 milliseconds.protected int
initialReconnectDelayMillis
protected boolean
streamEvenInBackground
-
Constructor Summary
Constructors Constructor Description StreamingDataSourceBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StreamingDataSourceBuilder
backgroundPollIntervalMillis(int backgroundPollIntervalMillis)
Sets the interval between feature flag updates when the application is running in the background.StreamingDataSourceBuilder
initialReconnectDelayMillis(int initialReconnectDelayMillis)
Sets the initial reconnect delay for the streaming connection.StreamingDataSourceBuilder
streamEvenInBackground(boolean streamEvenInBackground)
Sets whether streaming should be used even if the application is in the background.-
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_INITIAL_RECONNECT_DELAY_MILLIS
public static final int DEFAULT_INITIAL_RECONNECT_DELAY_MILLIS
The default value forinitialReconnectDelayMillis(int)
: 1000 milliseconds.- See Also:
- Constant Field Values
-
backgroundPollIntervalMillis
protected int backgroundPollIntervalMillis
-
initialReconnectDelayMillis
protected int initialReconnectDelayMillis
-
streamEvenInBackground
protected boolean streamEvenInBackground
-
-
Method Detail
-
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 isLDConfig.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
-
-