Skip to content

feat: Add support for http protocols option with flagsmith client #950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion providers/flagsmith/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<dependency>
<groupId>com.flagsmith</groupId>
<artifactId>flagsmith-java-client</artifactId>
<version>7.4.1</version>
<version>7.4.2</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.flagsmith.FlagsmithClient;
import com.flagsmith.config.FlagsmithCacheConfig;
import com.flagsmith.config.FlagsmithConfig;
import com.flagsmith.config.Retry;
import dev.openfeature.contrib.providers.flagsmith.exceptions.InvalidCacheOptionsException;
import dev.openfeature.contrib.providers.flagsmith.exceptions.InvalidOptionsException;
Expand Down Expand Up @@ -88,10 +89,8 @@ private static FlagsmithCacheConfig initializeCacheConfig(FlagsmithProviderOptio
* @param options The options used to create the provider
* @return a FlagsmithConfig object with the FlagsmithClient settings
*/
private static com.flagsmith.config.FlagsmithConfig initializeConfig(
FlagsmithProviderOptions options) {
com.flagsmith.config.FlagsmithConfig.Builder flagsmithConfig = com.flagsmith.config.FlagsmithConfig
.newBuilder();
private static FlagsmithConfig initializeConfig(FlagsmithProviderOptions options) {
FlagsmithConfig.Builder flagsmithConfig = FlagsmithConfig.newBuilder();

// Set client level configuration settings
if (options.getBaseUri() != null) {
Expand Down Expand Up @@ -136,6 +135,10 @@ private static com.flagsmith.config.FlagsmithConfig initializeConfig(
flagsmithConfig.withEnableAnalytics(options.isEnableAnalytics());
}

if (options.getSupportedProtocols() != null && !options.getSupportedProtocols().isEmpty()) {
flagsmithConfig.withSupportedProtocols(options.getSupportedProtocols());
}

return flagsmithConfig.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

import com.flagsmith.config.FlagsmithConfig.Protocol;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import lombok.Builder;
import lombok.Getter;
import javax.net.ssl.SSLSocketFactory;
Expand Down Expand Up @@ -183,4 +188,12 @@ public class FlagsmithProviderOptions {
*/
@Builder.Default
private boolean usingBooleanConfigValue = false;

/**
* Set the list of supported protocols that should be used.
* Optional.
* Default: All the enum protocols from FlagsmithConfig.
*/
@Builder.Default
private List<Protocol> supportedProtocols = Arrays.stream(Protocol.values()).collect(Collectors.toList());
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.flagsmith.config.FlagsmithConfig;
import dev.openfeature.contrib.providers.flagsmith.exceptions.InvalidCacheOptionsException;
import dev.openfeature.contrib.providers.flagsmith.exceptions.InvalidOptionsException;
import dev.openfeature.sdk.EvaluationContext;
Expand All @@ -16,6 +17,8 @@
import java.lang.reflect.Method;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -191,6 +194,7 @@ void shouldInitializeProviderWhenAllOptionsSet() {
.environmentRefreshIntervalSeconds(1)
.enableAnalytics(true)
.usingBooleanConfigValue(false)
.supportedProtocols(Collections.singletonList(FlagsmithConfig.Protocol.HTTP_1_1))
.build();
assertDoesNotThrow(() -> new FlagsmithProvider(options));
}
Expand Down
Loading