-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: In-memory provider for e2e testing and minimal usage (#546)
* Adds InMemoryProvider to enable simple testing and basic usage Signed-off-by: liran2000 <liran2000@gmail.com> Co-authored-by: Todd Baert <todd.baert@dynatrace.com>
- Loading branch information
Showing
13 changed files
with
489 additions
and
69 deletions.
There are no files selected for viewing
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
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
12 changes: 12 additions & 0 deletions
12
src/main/java/dev/openfeature/sdk/providers/memory/ContextEvaluator.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package dev.openfeature.sdk.providers.memory; | ||
|
||
import dev.openfeature.sdk.EvaluationContext; | ||
|
||
/** | ||
* Context evaluator - use for resolving flag according to evaluation context, for handling targeting. | ||
* @param <T> expected value type | ||
*/ | ||
public interface ContextEvaluator<T> { | ||
|
||
T evaluate(Flag flag, EvaluationContext evaluationContext); | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/dev/openfeature/sdk/providers/memory/Flag.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package dev.openfeature.sdk.providers.memory; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.Singular; | ||
import lombok.ToString; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Flag representation for the in-memory provider. | ||
*/ | ||
@ToString | ||
@Builder | ||
@Getter | ||
public class Flag<T> { | ||
@Singular | ||
private Map<String, Object> variants; | ||
private String defaultVariant; | ||
private ContextEvaluator<T> contextEvaluator; | ||
} |
Oops, something went wrong.