-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix Java OpenFeature docs * Update java.mdx
- Loading branch information
Showing
14 changed files
with
78 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ import TabItem from '@theme/TabItem'; | |
```groovy title="build.gradle" | ||
dependencies { | ||
implementation 'dev.openfeature.contrib.providers:configcat:0.0.4' | ||
implementation 'dev.openfeature:sdk:1.+' | ||
} | ||
``` | ||
|
||
|
@@ -27,9 +28,14 @@ dependencies { | |
|
||
```xml title="pom.xml" | ||
<dependency> | ||
<groupId>dev.openfeature.contrib.providers</groupId> | ||
<artifactId>configcat</artifactId> | ||
<version>0.0.4</version> | ||
<groupId>dev.openfeature.contrib.providers</groupId> | ||
<artifactId>configcat</artifactId> | ||
<version>0.0.4</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>dev.openfeature</groupId> | ||
<artifactId>sdk</artifactId> | ||
<version>[1.0,)</version> | ||
</dependency> | ||
``` | ||
|
||
|
@@ -42,10 +48,13 @@ The `ConfigCatProvider` constructor takes a `ConfigCatProviderConfig` argument c | |
```java | ||
// Build options for the ConfigCat SDK. | ||
ConfigCatProviderConfig configCatProviderConfig = ConfigCatProviderConfig.builder() | ||
.sdkKey("#YOUR-SDK-KEY#") | ||
.pollingMode(PollingModes.autoPoll()) | ||
.logLevel(LogLevel.WARNING) | ||
.build(); | ||
.sdkKey("#YOUR-SDK-KEY#") | ||
.options(options -> { | ||
options.pollingMode(PollingModes.autoPoll()); | ||
options.logLevel(LogLevel.WARNING); | ||
// ... | ||
}) | ||
.build(); | ||
|
||
// Configure the provider. | ||
OpenFeatureAPI.getInstance().setProviderAndWait(new ConfigCatProvider(configCatProviderConfig)); | ||
|
@@ -60,7 +69,7 @@ For more information about all the configuration options, see the [Java SDK docu | |
|
||
```java | ||
boolean isAwesomeFeatureEnabled = client.getBooleanValue("isAwesomeFeatureEnabled", false); | ||
if(isAwesomeFeatureEnabled) | ||
if (isAwesomeFeatureEnabled) | ||
{ | ||
doTheNewThing(); | ||
} | ||
|
@@ -70,6 +79,14 @@ else | |
} | ||
``` | ||
|
||
### 4. Cleaning up | ||
|
||
On application shutdown, clean up the OpenFeature provider and the underlying ConfigCat client. | ||
|
||
```cs | ||
OpenFeatureAPI.getInstance().shutdown(); | ||
``` | ||
|
||
## Evaluation Context | ||
|
||
An <a href="https://openfeature.dev/docs/reference/concepts/evaluation-context" target="_blank">evaluation context</a> in the OpenFeature specification is a container for arbitrary contextual data that can be used as a basis for feature flag evaluation. | ||
|
@@ -87,11 +104,11 @@ The following table shows how the different context attributes are mapped to Use | |
To evaluate feature flags for a context, use the <a href="https://openfeature.dev/docs/reference/concepts/evaluation-api/" target="_blank">OpenFeature Evaluation API</a>: | ||
|
||
```java | ||
MutableContext evaluationContext = new MutableContext(); | ||
evaluationContext.setTargetingKey("#SOME-USER-ID#"); | ||
evaluationContext.add("Email", "[email protected]"); | ||
evaluationContext.add("Country", "CountryID"); | ||
evaluationContext.add("Rating", 4.5); | ||
MutableContext context = new MutableContext(); | ||
context.setTargetingKey("#SOME-USER-ID#"); | ||
context.add("Email", "[email protected]"); | ||
context.add("Country", "CountryID"); | ||
context.add("Rating", 4.5); | ||
|
||
boolean isAwesomeFeatureEnabled = client.getBooleanValue("isAwesomeFeatureEnabled", false, context); | ||
``` | ||
|
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
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 |
---|---|---|
|
@@ -19,6 +19,7 @@ import TabItem from '@theme/TabItem'; | |
```groovy title="build.gradle" | ||
dependencies { | ||
implementation 'dev.openfeature.contrib.providers:configcat:0.0.4' | ||
implementation 'dev.openfeature:sdk:1.+' | ||
} | ||
``` | ||
|
||
|
@@ -27,9 +28,14 @@ dependencies { | |
|
||
```xml title="pom.xml" | ||
<dependency> | ||
<groupId>dev.openfeature.contrib.providers</groupId> | ||
<artifactId>configcat</artifactId> | ||
<version>0.0.4</version> | ||
<groupId>dev.openfeature.contrib.providers</groupId> | ||
<artifactId>configcat</artifactId> | ||
<version>0.0.4</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>dev.openfeature</groupId> | ||
<artifactId>sdk</artifactId> | ||
<version>[1.0,)</version> | ||
</dependency> | ||
``` | ||
|
||
|
@@ -42,10 +48,13 @@ The `ConfigCatProvider` constructor takes a `ConfigCatProviderConfig` argument c | |
```java | ||
// Build options for the ConfigCat SDK. | ||
ConfigCatProviderConfig configCatProviderConfig = ConfigCatProviderConfig.builder() | ||
.sdkKey("#YOUR-SDK-KEY#") | ||
.pollingMode(PollingModes.autoPoll()) | ||
.logLevel(LogLevel.WARNING) | ||
.build(); | ||
.sdkKey("#YOUR-SDK-KEY#") | ||
.options(options -> { | ||
options.pollingMode(PollingModes.autoPoll()); | ||
options.logLevel(LogLevel.WARNING); | ||
// ... | ||
}) | ||
.build(); | ||
|
||
// Configure the provider. | ||
OpenFeatureAPI.getInstance().setProviderAndWait(new ConfigCatProvider(configCatProviderConfig)); | ||
|
@@ -60,7 +69,7 @@ For more information about all the configuration options, see the [Java SDK docu | |
|
||
```java | ||
boolean isAwesomeFeatureEnabled = client.getBooleanValue("isAwesomeFeatureEnabled", false); | ||
if(isAwesomeFeatureEnabled) | ||
if (isAwesomeFeatureEnabled) | ||
{ | ||
doTheNewThing(); | ||
} | ||
|
@@ -70,6 +79,14 @@ else | |
} | ||
``` | ||
|
||
### 4. Cleaning up | ||
|
||
On application shutdown, clean up the OpenFeature provider and the underlying ConfigCat client. | ||
|
||
```cs | ||
OpenFeatureAPI.getInstance().shutdown(); | ||
``` | ||
|
||
## Evaluation Context | ||
|
||
An <a href="https://openfeature.dev/docs/reference/concepts/evaluation-context" target="_blank">evaluation context</a> in the OpenFeature specification is a container for arbitrary contextual data that can be used as a basis for feature flag evaluation. | ||
|
@@ -87,11 +104,11 @@ The following table shows how the different context attributes are mapped to Use | |
To evaluate feature flags for a context, use the <a href="https://openfeature.dev/docs/reference/concepts/evaluation-api/" target="_blank">OpenFeature Evaluation API</a>: | ||
|
||
```java | ||
MutableContext evaluationContext = new MutableContext(); | ||
evaluationContext.setTargetingKey("#SOME-USER-ID#"); | ||
evaluationContext.add("Email", "[email protected]"); | ||
evaluationContext.add("Country", "CountryID"); | ||
evaluationContext.add("Rating", 4.5); | ||
MutableContext context = new MutableContext(); | ||
context.setTargetingKey("#SOME-USER-ID#"); | ||
context.add("Email", "[email protected]"); | ||
context.add("Country", "CountryID"); | ||
context.add("Rating", 4.5); | ||
|
||
boolean isAwesomeFeatureEnabled = client.getBooleanValue("isAwesomeFeatureEnabled", false, context); | ||
``` | ||
|
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