Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit 7b18e04

Browse files
authored
Merge pull request #26 from eplusminus/eb/config-minimum-and-warning
increase minimum polling interval to 30s and add warning to streaming parameter
2 parents 8a9d6b9 + caeb5eb commit 7b18e04

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

src/main/java/com/launchdarkly/client/LDClient.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public LDClient(String sdkKey, LDConfig config) {
7979
this.updateProcessor = createStreamProcessor(sdkKey, config, requestor);
8080
} else {
8181
logger.info("Disabling streaming API");
82+
logger.warn("You should only disable the streaming API if instructed to do so by LaunchDarkly support");
8283
this.updateProcessor = createPollingProcessor(config);
8384
}
8485

src/main/java/com/launchdarkly/client/LDConfig.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public final class LDConfig {
3434
private static final int DEFAULT_CONNECT_TIMEOUT_MILLIS = 2000;
3535
private static final int DEFAULT_SOCKET_TIMEOUT_MILLIS = 10000;
3636
private static final int DEFAULT_FLUSH_INTERVAL_SECONDS = 5;
37-
private static final long DEFAULT_POLLING_INTERVAL_MILLIS = 1000L;
37+
private static final long MIN_POLLING_INTERVAL_MILLIS = 30000L;
3838
private static final long DEFAULT_START_WAIT_MILLIS = 5000L;
3939
private static final int DEFAULT_SAMPLING_INTERVAL = 0;
4040

@@ -78,8 +78,8 @@ protected LDConfig(Builder builder) {
7878
this.useLdd = builder.useLdd;
7979
this.offline = builder.offline;
8080
this.sendEvents = builder.sendEvents;
81-
if (builder.pollingIntervalMillis < DEFAULT_POLLING_INTERVAL_MILLIS) {
82-
this.pollingIntervalMillis = DEFAULT_POLLING_INTERVAL_MILLIS;
81+
if (builder.pollingIntervalMillis < MIN_POLLING_INTERVAL_MILLIS) {
82+
this.pollingIntervalMillis = MIN_POLLING_INTERVAL_MILLIS;
8383
} else {
8484
this.pollingIntervalMillis = builder.pollingIntervalMillis;
8585
}
@@ -152,7 +152,7 @@ public static class Builder {
152152
private boolean useLdd = false;
153153
private boolean offline = false;
154154
private boolean sendEvents = true;
155-
private long pollingIntervalMillis = DEFAULT_POLLING_INTERVAL_MILLIS;
155+
private long pollingIntervalMillis = MIN_POLLING_INTERVAL_MILLIS;
156156
private FeatureStore featureStore = new InMemoryFeatureStore();
157157
private long startWaitMillis = DEFAULT_START_WAIT_MILLIS;
158158
private int samplingInterval = DEFAULT_SAMPLING_INTERVAL;
@@ -203,7 +203,8 @@ public Builder featureStore(FeatureStore store) {
203203
}
204204

205205
/**
206-
* Set whether streaming mode should be enabled. By default, streaming is enabled.
206+
* Set whether streaming mode should be enabled. By default, streaming is enabled. It should only be
207+
* disabled on the advice of LaunchDarkly support.
207208
*
208209
* @param stream whether streaming mode should be enabled
209210
* @return the builder
@@ -392,8 +393,8 @@ public Builder sendEvents(boolean sendEvents) {
392393
}
393394

394395
/**
395-
* Set the polling interval (when streaming is disabled). Values less than the default of 1000
396-
* will be set to 1000.
396+
* Set the polling interval (when streaming is disabled). Values less than the default of
397+
* 30000 will be set to the default.
397398
*
398399
* @param pollingIntervalMillis rule update polling interval in milliseconds.
399400
* @return the builder

src/test/java/com/launchdarkly/client/LDConfigTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ public void testProxyAuthPartialConfig() {
9898
@Test
9999
public void testMinimumPollingIntervalIsEnforcedProperly(){
100100
LDConfig config = new LDConfig.Builder().pollingIntervalMillis(10L).build();
101-
assertEquals(1000L, config.pollingIntervalMillis);
101+
assertEquals(30000L, config.pollingIntervalMillis);
102102
}
103103

104104
@Test
105105
public void testPollingIntervalIsEnforcedProperly(){
106-
LDConfig config = new LDConfig.Builder().pollingIntervalMillis(10001L).build();
107-
assertEquals(10001L, config.pollingIntervalMillis);
106+
LDConfig config = new LDConfig.Builder().pollingIntervalMillis(30001L).build();
107+
assertEquals(30001L, config.pollingIntervalMillis);
108108
}
109109

110110
@Test

0 commit comments

Comments
 (0)