Class StreamingDataSourceBuilder
- All Implemented Interfaces:
ComponentConfigurer<DataSource>
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 Summary
Modifier and TypeFieldDescriptionprotected int
Background polling interval in millisstatic final int
The default value forinitialReconnectDelayMillis(int)
: 1000 milliseconds.protected int
The initial reconnection delay in millisprotected boolean
True if the data source will attempt to continue streaming when in the background -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbackgroundPollIntervalMillis
(int backgroundPollIntervalMillis) Sets the interval between feature flag updates when the application is running in the background.initialReconnectDelayMillis
(int initialReconnectDelayMillis) Sets the initial reconnect delay for the streaming connection.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 Details
-
DEFAULT_INITIAL_RECONNECT_DELAY_MILLIS
public static final int DEFAULT_INITIAL_RECONNECT_DELAY_MILLISThe default value forinitialReconnectDelayMillis(int)
: 1000 milliseconds.- See Also:
-
backgroundPollIntervalMillis
protected int backgroundPollIntervalMillisBackground polling interval in millis -
initialReconnectDelayMillis
protected int initialReconnectDelayMillisThe initial reconnection delay in millis -
streamEvenInBackground
protected boolean streamEvenInBackgroundTrue if the data source will attempt to continue streaming when in the background
-
-
Constructor Details
-
StreamingDataSourceBuilder
public StreamingDataSourceBuilder()
-
-
Method Details
-
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
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
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
-