Update the LDClient configuration to use a defined Relay Proxy.
Before:
import com.launchdarkly.sdk.LDContext;
import com.launchdarkly.sdk.server.LDClient;
class Test {
public void a() {
LDClient client = new LDClient("sdk-key");
LDContext context = LDContext.builder("context-key")
.name("user")
.build();
boolean flagValue = client.boolVariation("flag-key-123abc", context, false);
if (flagValue) {
// Application code to show the feature
} else {
// The code to run if the feature is off
}
}
}
After (5.9 or later):
import com.launchdarkly.sdk.LDContext;
import com.launchdarkly.sdk.server.LDClient;
class Test {
public void a() {
LDClient client = new LDClient("sdk-key", new LDConfig.Builder()
.serviceEndpoints(Components.serviceEndpoints()
.relayProxy("https://your-relay-proxy.com:8030"))
.build());
LDContext context = LDContext.builder("context-key")
.name("user")
.build();
boolean flagValue = client.boolVariation("flag-key-123abc", context, false);
if (flagValue) {
// Application code to show the feature
} else {
// The code to run if the feature is off
}
}
}
After (5.8 or earlier):
import com.launchdarkly.sdk.LDContext;
import com.launchdarkly.sdk.server.LDClient;
class Test {
public void a() {
LDClient client = new LDClient("sdk-key", LDConfig.Builder()
.dataSource(Components.streamingDataSource()
.baseURI(URI.create("https://your-relay-proxy.com:8030"))
.events(Components.sendEvents()
.baseURI(URI.create("https://your-relay-proxy.com:8030"))
.build());
LDContext context = LDContext.builder("context-key")
.name("user")
.build();
boolean flagValue = client.boolVariation("flag-key-123abc", context, false);
if (flagValue) {
// Application code to show the feature
} else {
// The code to run if the feature is off
}
}
}
Update the
LDClient
configuration to use a defined Relay Proxy.Before:
After (5.9 or later):
After (5.8 or earlier):