-
Notifications
You must be signed in to change notification settings - Fork 51
feat!: update to sdk 0.3.0 #116
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
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
hooks/open-telemetry/src/main/java/dev/openfeature/contrib/hooks/otel/OpenTelemetryHook.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,37 @@ | ||
package dev.openfeature.contrib.providers.gofeatureflag; | ||
|
||
import static java.net.HttpURLConnection.HTTP_BAD_REQUEST; | ||
|
||
import java.io.IOException; | ||
import java.time.Instant; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.stream.Collectors; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.SerializationFeature; | ||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; | ||
|
||
import dev.openfeature.contrib.providers.gofeatureflag.bean.GoFeatureFlagRequest; | ||
import dev.openfeature.contrib.providers.gofeatureflag.bean.GoFeatureFlagResponse; | ||
import dev.openfeature.contrib.providers.gofeatureflag.bean.GoFeatureFlagUser; | ||
import dev.openfeature.contrib.providers.gofeatureflag.exception.InvalidEndpoint; | ||
import dev.openfeature.contrib.providers.gofeatureflag.exception.InvalidOptions; | ||
import dev.openfeature.javasdk.ErrorCode; | ||
import dev.openfeature.javasdk.EvaluationContext; | ||
import dev.openfeature.javasdk.FeatureProvider; | ||
import dev.openfeature.javasdk.Hook; | ||
import dev.openfeature.javasdk.Metadata; | ||
import dev.openfeature.javasdk.ProviderEvaluation; | ||
import dev.openfeature.javasdk.Reason; | ||
import dev.openfeature.javasdk.Structure; | ||
import dev.openfeature.javasdk.Value; | ||
import dev.openfeature.javasdk.exceptions.FlagNotFoundError; | ||
import dev.openfeature.javasdk.exceptions.GeneralError; | ||
import dev.openfeature.javasdk.exceptions.OpenFeatureError; | ||
import dev.openfeature.javasdk.exceptions.TypeMismatchError; | ||
import dev.openfeature.sdk.ErrorCode; | ||
import dev.openfeature.sdk.EvaluationContext; | ||
import dev.openfeature.sdk.FeatureProvider; | ||
import dev.openfeature.sdk.Hook; | ||
import dev.openfeature.sdk.Metadata; | ||
import dev.openfeature.sdk.MutableStructure; | ||
import dev.openfeature.sdk.ProviderEvaluation; | ||
import dev.openfeature.sdk.Reason; | ||
import dev.openfeature.sdk.Structure; | ||
import dev.openfeature.sdk.Value; | ||
import dev.openfeature.sdk.exceptions.FlagNotFoundError; | ||
import dev.openfeature.sdk.exceptions.GeneralError; | ||
import dev.openfeature.sdk.exceptions.OpenFeatureError; | ||
import dev.openfeature.sdk.exceptions.TypeMismatchError; | ||
import okhttp3.ConnectionPool; | ||
import okhttp3.HttpUrl; | ||
import okhttp3.MediaType; | ||
|
@@ -30,15 +41,6 @@ | |
import okhttp3.Response; | ||
import okhttp3.ResponseBody; | ||
|
||
import java.io.IOException; | ||
import java.time.Instant; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.stream.Collectors; | ||
|
||
import static java.net.HttpURLConnection.HTTP_BAD_REQUEST; | ||
|
||
/** | ||
* GoFeatureFlagProvider is the JAVA provider implementation for the feature flag solution GO Feature Flag. | ||
*/ | ||
|
@@ -199,7 +201,8 @@ private <T> ProviderEvaluation<T> resolveEvaluationGoFeatureFlagProxy( | |
if (Reason.DISABLED.name().equalsIgnoreCase(goffResp.getReason())) { | ||
// we don't set a variant since we are using the default value, and we are not able to know | ||
// which variant it is. | ||
return ProviderEvaluation.<T>builder().value(defaultValue).reason(Reason.DISABLED).build(); | ||
return ProviderEvaluation.<T>builder().value(defaultValue).reason(Reason.DISABLED.toString()) | ||
.build(); | ||
} | ||
|
||
if (ErrorCode.FLAG_NOT_FOUND.name().equalsIgnoreCase(goffResp.getErrorCode())) { | ||
|
@@ -215,8 +218,7 @@ private <T> ProviderEvaluation<T> resolveEvaluationGoFeatureFlagProxy( | |
} | ||
|
||
return ProviderEvaluation.<T>builder() | ||
.errorCode(goffResp.getErrorCode()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed the error code here. I think that if we got this far, we don't need the error? Otherwise we should probably throw. I think this is the biggest GOFF change I made. |
||
.reason(mapReason(goffResp.getReason())) | ||
.reason(goffResp.getReason()) | ||
.value(flagValue) | ||
.variant(goffResp.getVariationType()) | ||
.build(); | ||
|
@@ -227,22 +229,6 @@ private <T> ProviderEvaluation<T> resolveEvaluationGoFeatureFlagProxy( | |
} | ||
} | ||
|
||
|
||
/** | ||
* mapReason is mapping the reason in string received by the API to our internal SDK reason enum. | ||
* | ||
* @param reason - string of the reason received from the API | ||
* @return an item from the enum | ||
*/ | ||
private Reason mapReason(String reason) { | ||
try { | ||
return Reason.valueOf(reason); | ||
} catch (IllegalArgumentException e) { | ||
return Reason.UNKNOWN; | ||
} | ||
} | ||
|
||
|
||
/** | ||
* convertValue is converting the object return by the proxy response in the right type. | ||
* | ||
|
@@ -303,7 +289,7 @@ private Value objectToValue(Object object) { | |
* @return a Structure object in the SDK format | ||
*/ | ||
private Structure mapToStructure(Map<String, Object> map) { | ||
return new Structure( | ||
return new MutableStructure( | ||
map.entrySet().stream() | ||
.filter(e -> e.getValue() != null) | ||
.collect(Collectors.toMap(Map.Entry::getKey, e -> objectToValue(e.getValue())))); | ||
|
4 changes: 2 additions & 2 deletions
4
...src/main/java/dev/openfeature/contrib/providers/gofeatureflag/bean/GoFeatureFlagUser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...n/java/dev/openfeature/contrib/providers/gofeatureflag/exception/InvalidTargetingKey.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reasons are strings now.