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

Commit 3042627

Browse files
committed
Support for LDD
1 parent 0602c8e commit 3042627

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

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

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public final class LDConfig {
3434
final boolean stream;
3535
final boolean debugStreaming;
3636
final FeatureStore featureStore;
37+
final boolean useLdd;
3738

3839
protected LDConfig(Builder builder) {
3940
this.baseURI = builder.baseURI;
@@ -46,6 +47,7 @@ protected LDConfig(Builder builder) {
4647
this.stream = builder.stream;
4748
this.debugStreaming = builder.debugStreaming;
4849
this.featureStore = builder.featureStore;
50+
this.useLdd = builder.useLdd;
4951
}
5052

5153
/**
@@ -72,6 +74,7 @@ public static class Builder{
7274
private String proxyScheme;
7375
private boolean stream = true;
7476
private boolean debugStreaming = false;
77+
private boolean useLdd = false;
7578
private FeatureStore featureStore = new InMemoryFeatureStore();
7679

7780
/**
@@ -110,7 +113,7 @@ public Builder featureStore(FeatureStore store) {
110113
* retrieved feature with the value in the feature store. There is a performance cost to this, so it is not
111114
* recommended for production use.
112115
* @param debugStreaming whether streaming mode should be debugged
113-
* @return
116+
* @return the builder
114117
*/
115118
public Builder debugStreaming(boolean debugStreaming) {
116119
this.debugStreaming = debugStreaming;
@@ -215,7 +218,7 @@ public Builder capacity(int capacity) {
215218
* a proxy will not be used, and {@link LDClient} will connect to LaunchDarkly directly.
216219
* </p>
217220
* @param host
218-
* @return
221+
* @return the builder
219222
*/
220223
public Builder proxyHost(String host) {
221224
this.proxyHost = host;
@@ -231,7 +234,7 @@ public Builder proxyHost(String host) {
231234
* a proxy will not be used, and {@link LDClient} will connect to LaunchDarkly directly.
232235
* </p>
233236
* @param port
234-
* @return
237+
* @return the builder
235238
*/
236239
public Builder proxyPort(int port) {
237240
this.proxyPort = port;
@@ -247,13 +250,24 @@ public Builder proxyPort(int port) {
247250
* a proxy will not be used, and {@link LDClient} will connect to LaunchDarkly directly.
248251
* </p>
249252
* @param scheme
250-
* @return
253+
* @return the builder
251254
*/
252255
public Builder proxyScheme(String scheme) {
253256
this.proxyScheme = scheme;
254257
return this;
255258
}
256259

260+
/**
261+
* Set whether this client should subscribe to the streaming API, or whether the LaunchDarkly daemon is in use
262+
* instead
263+
* @param useLdd
264+
* @return the builder
265+
*/
266+
public Builder useLdd(boolean useLdd) {
267+
this.useLdd = useLdd;
268+
return this;
269+
}
270+
257271
HttpHost proxyHost() {
258272
if (this.proxyHost == null && this.proxyPort == -1 && this.proxyScheme == null) {
259273
return null;

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ class StreamProcessor implements Closeable {
4242
}
4343

4444
void subscribe() {
45+
// If the LaunchDarkly daemon is to be used, then do not subscribe to the stream
46+
if (config.useLdd) {
47+
return;
48+
}
49+
4550
MultivaluedMap<String, Object> headers = new StringKeyIgnoreCaseMultivaluedMap<Object>();
4651
headers.putSingle("Authorization", "api_key " + this.apiKey);
4752
headers.putSingle("User-Agent", "JavaClient/" + LDClient.CLIENT_VERSION);

0 commit comments

Comments
 (0)