Class PollingDataSourceBuilder
- java.lang.Object
-
- com.launchdarkly.sdk.server.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. 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()
, change its properties with the methods of this class, and pass it toLDConfig.Builder.dataSource(ComponentConfigurer)
:LDConfig config = new LDConfig.Builder() .dataSource(Components.pollingDataSource().pollInterval(Duration.ofSeconds(45))) .build();
Note that this class is abstract; the actual implementation is created by calling
Components.pollingDataSource()
.- Since:
- 4.12.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.time.Duration
DEFAULT_POLL_INTERVAL
The default and minimum value forpollInterval(Duration)
: 30 seconds.protected java.lang.String
payloadFilter
protected java.time.Duration
pollInterval
-
Constructor Summary
Constructors Constructor Description PollingDataSourceBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PollingDataSourceBuilder
payloadFilter(java.lang.String payloadFilter)
Sets the Payload Filter that will be used to filter the objects (flags, segments, etc.) from this data source.PollingDataSourceBuilder
pollInterval(java.time.Duration pollInterval)
Sets the interval at which the SDK will poll for feature flag updates.-
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.server.subsystems.ComponentConfigurer
build
-
-
-
-
Field Detail
-
DEFAULT_POLL_INTERVAL
public static final java.time.Duration DEFAULT_POLL_INTERVAL
The default and minimum value forpollInterval(Duration)
: 30 seconds.
-
pollInterval
protected java.time.Duration pollInterval
-
payloadFilter
protected java.lang.String payloadFilter
-
-
Method Detail
-
pollInterval
public PollingDataSourceBuilder pollInterval(java.time.Duration pollInterval)
Sets the interval at which the SDK will poll for feature flag updates.The default and minimum value is
DEFAULT_POLL_INTERVAL
. Values less than this will be set to the default.- Parameters:
pollInterval
- the polling interval; null to use the default- Returns:
- the builder
-
payloadFilter
public PollingDataSourceBuilder payloadFilter(java.lang.String payloadFilter)
Sets the Payload Filter that will be used to filter the objects (flags, segments, etc.) from this data source.- Parameters:
payloadFilter
- the filter to be used- Returns:
- the builder
-
-