Skip to content

Commit a58a64e

Browse files
authored
docs(configcat): Revise docs in README.md (#990)
Signed-off-by: Peter Csajtai <[email protected]>
1 parent 1e53431 commit a58a64e

File tree

1 file changed

+37
-19
lines changed

1 file changed

+37
-19
lines changed

providers/configcat/README.md

+37-19
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
# Unofficial ConfigCat OpenFeature Provider for Java
1+
# ConfigCat OpenFeature Provider for Java
22

3-
[ConfigCat](https://configcat.com/) OpenFeature Provider can provide usage for ConfigCat via OpenFeature Java SDK.
3+
[ConfigCat](https://configcat.com/) OpenFeature Provider can provide usage for ConfigCat via the OpenFeature Java SDK.
44

55
## Installation
66

77
<!-- x-release-please-start-version -->
88

99
```xml
10-
1110
<dependency>
1211
<groupId>dev.openfeature.contrib.providers</groupId>
1312
<artifactId>configcat</artifactId>
@@ -18,35 +17,54 @@
1817
<!-- x-release-please-end-version -->
1918

2019
## Usage
21-
ConfigCat OpenFeature Provider is using ConfigCat Java SDK.
20+
The ConfigCat OpenFeature Provider uses a ConfigCat Java SDK client for evaluating feature flags.
2221

2322
### Usage Example
2423

25-
```
26-
ConfigCatProviderConfig configCatProviderConfig = ConfigCatProviderConfig.builder().sdkKey(sdkKey).build();
27-
configCatProvider = new ConfigCatProvider(configCatProviderConfig);
24+
The following example shows how to use the provider with the OpenFeature SDK.
25+
26+
```java
27+
// Build options for the ConfigCat SDK.
28+
ConfigCatProviderConfig configCatProviderConfig = ConfigCatProviderConfig.builder()
29+
.sdkKey("#YOUR-SDK-KEY#")
30+
.options(options -> {
31+
options.pollingMode(PollingModes.autoPoll());
32+
options.logLevel(LogLevel.WARNING);
33+
// ...
34+
})
35+
.build();
36+
37+
ConfigCatProvider configCatProvider = new ConfigCatProvider(configCatProviderConfig);
38+
39+
// Configure the provider.
2840
OpenFeatureAPI.getInstance().setProviderAndWait(configCatProvider);
29-
boolean featureEnabled = client.getBooleanValue(FLAG_NAME, false);
3041

31-
MutableContext evaluationContext = new MutableContext();
32-
evaluationContext.setTargetingKey("[email protected]");
33-
evaluationContext.add("Email", "[email protected]");
34-
evaluationContext.add("Country", "someCountry");
35-
featureEnabled = client.getBooleanValue(USERS_FLAG_NAME, false, evaluationContext);
36-
```
42+
// Create a client.
43+
Client client = OpenFeatureAPI.getInstance().getClient();
3744

38-
See [ConfigCatProviderTest.java](./src/test/java/dev/openfeature/contrib/providers/configcat/ConfigCatProviderTest.java)
39-
for more information.
45+
// Evaluate your feature flag.
46+
boolean isAwesomeFeatureEnabled = client.getBooleanValue("isAwesomeFeatureEnabled", false);
47+
48+
// With evaluation context.
49+
MutableContext context = new MutableContext();
50+
context.setTargetingKey("#SOME-USER-ID#");
51+
context.add("Email", "[email protected]");
52+
context.add("Country", "CountryID");
53+
context.add("Rating", 4.5);
54+
55+
boolean isAwesomeFeatureEnabled = client.getBooleanValue("isAwesomeFeatureEnabled", false, context);
56+
```
57+
For a full list of configuration options see the [ConfigCat Java SDK documentation](https://configcat.com/docs/sdk-reference/java/#creating-the-configcat-client).
4058

4159
## Notes
42-
Some ConfigCat custom operations are supported from the provider client via:
60+
The underlying ConfigCat Client is accessible via the provider's `getConfigCatClient()` function:
4361

4462
```java
4563
configCatProvider.getConfigCatClient()...
4664
```
4765

48-
## ConfigCat Provider Tests Strategies
66+
## ConfigCat Provider Test Strategy
4967

50-
Unit test based on ConfigCat local features file.
68+
Unit tests are based on the SDK's [local file override](https://configcat.com/docs/sdk-reference/java/#flag-overrides) feature.
5169
See [ConfigCatProviderTest.java](./src/test/java/dev/openfeature/contrib/providers/configcat/ConfigCatProviderTest.java)
5270
for more information.

0 commit comments

Comments
 (0)