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

Commit 748b76e

Browse files
committed
added debugStreaming config parameter
1 parent 1f33074 commit 748b76e

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ public boolean toggle(String featureKey, LDUser user, boolean defaultValue) {
190190
if (this.config.stream && this.streamProcessor != null && this.streamProcessor.initialized()) {
191191
logger.debug("Using feature flag stored from streaming API");
192192
result = (FeatureRep<Boolean>) this.streamProcessor.getFeature(featureKey);
193-
if (logger.isDebugEnabled()) {
193+
if (config.debugStreaming) {
194194
FeatureRep<Boolean> pollingResult = fetchFeature(featureKey);
195195
if (!result.equals(pollingResult)) {
196-
logger.debug("Mismatch between streaming and polling feature! Streaming: {} Polling: {}", result, pollingResult);
196+
logger.warn("Mismatch between streaming and polling feature! Streaming: {} Polling: {}", result, pollingResult);
197197
}
198198
}
199199
} else {

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public final class LDConfig {
3232
final int flushInterval;
3333
final HttpHost proxyHost;
3434
final boolean stream;
35+
final boolean debugStreaming;
3536

3637
protected LDConfig(Builder builder) {
3738
this.baseURI = builder.baseURI;
@@ -42,6 +43,7 @@ protected LDConfig(Builder builder) {
4243
this.proxyHost = builder.proxyHost();
4344
this.streamURI = builder.streamURI;
4445
this.stream = builder.stream;
46+
this.debugStreaming = builder.debugStreaming;
4547
}
4648

4749
/**
@@ -67,6 +69,7 @@ public static class Builder{
6769
private int proxyPort = -1;
6870
private String proxyScheme;
6971
private boolean stream = false;
72+
private boolean debugStreaming = false;
7073

7174
/**
7275
* Creates a builder with all configuration parameters set to the default
@@ -94,6 +97,18 @@ public Builder streamURI(URI streamURI) {
9497
return this;
9598
}
9699

100+
/**
101+
* Set whether we should debug streaming mode. If set, the client will fetch features via polling and compare the
102+
* retrieved feature with the value in the feature store. There is a performance cost to this, so it is not
103+
* recommended for production use.
104+
* @param debugStreaming whether streaming mode should be debugged
105+
* @return
106+
*/
107+
public Builder debugStreaming(boolean debugStreaming) {
108+
this.debugStreaming = debugStreaming;
109+
return this;
110+
}
111+
97112
/**
98113
* Set whether streaming mode should be enabled
99114
* @param stream whether streaming mode should be enabled

0 commit comments

Comments
 (0)