|
1 | | -### Todo |
| 1 | +# OFREP Provider for OpenFeature |
| 2 | + |
| 3 | +This provider allows to connect to any feature flag management system that supports OFREP. |
| 4 | + |
| 5 | +## Installation |
| 6 | +For Maven |
| 7 | +<!-- x-release-please-start-version --> |
| 8 | +```xml |
| 9 | +<dependency> |
| 10 | + <groupId>dev.openfeature.contrib.providers</groupId> |
| 11 | + <artifactId>ofrep</artifactId> |
| 12 | + <version>0.0.1</version> |
| 13 | +</dependency> |
| 14 | +``` |
| 15 | + |
| 16 | +For Gradle |
| 17 | +```groovy |
| 18 | +implementation 'dev.openfeature.contrib.providers:ofrep:0.0.1' |
| 19 | +``` |
| 20 | +<!-- x-release-please-end-version --> |
| 21 | + |
| 22 | +## Configuration and Usage |
| 23 | + |
| 24 | +### Usage |
| 25 | +```java |
| 26 | +OfrepProviderOptions options = OfrepProviderOptions.builder().build(); |
| 27 | +OfrepProvider ofrepProvider = OfrepProvider.constructProvider(options); |
| 28 | +``` |
| 29 | +### Example |
| 30 | +```java |
| 31 | +import dev.openfeature.contrib.providers.ofrep.OfrepProvider; |
| 32 | +import dev.openfeature.contrib.providers.ofrep.OfrepProviderOptions; |
| 33 | +import dev.openfeature.sdk.Client; |
| 34 | +import dev.openfeature.sdk.FlagEvaluationDetails; |
| 35 | +import dev.openfeature.sdk.MutableContext; |
| 36 | +import dev.openfeature.sdk.OpenFeatureAPI; |
| 37 | + |
| 38 | +public class App { |
| 39 | + public static void main(String[] args) { |
| 40 | + OpenFeatureAPI openFeatureAPI = OpenFeatureAPI.getInstance(); |
| 41 | + |
| 42 | + OfrepProviderOptions options = OfrepProviderOptions.builder().build(); |
| 43 | + OfrepProvider ofrepProvider = OfrepProvider.constructProvider(options); |
| 44 | + |
| 45 | + openFeatureAPI.setProvider(ofrepProvider); |
| 46 | + |
| 47 | + Client client = openFeatureAPI.getClient(); |
| 48 | + |
| 49 | + MutableContext context = new MutableContext(); |
| 50 | + context.setTargetingKey("my-identify-id"); |
| 51 | + |
| 52 | + FlagEvaluationDetails<Boolean> details = client.getBooleanDetails("my-boolean-flag", false, context); |
| 53 | + System.out.println("Flag value: " + details.getValue()); |
| 54 | + |
| 55 | + openFeatureAPI.shutdown(); |
| 56 | + } |
| 57 | +} |
| 58 | +``` |
| 59 | + |
| 60 | +### Configuration options |
| 61 | + |
| 62 | +Options are passed via `OfrepProviderOptions`, using which default values can be overridden. |
| 63 | + |
| 64 | +Given below are the supported configurations: |
| 65 | + |
| 66 | + |
| 67 | +| Option name | Type | Default | Description |
| 68 | +| ----------- | ------- | --------- | --------- |
| 69 | +| baseUrl | String | http://localhost:8016 | Override the default OFREP API URL. |
| 70 | +| headers | ImmutableMap | Empty Map | Add custom headers which will be sent with each network request to the OFREP API. |
| 71 | +| timeout | Duration | 10 Seconds | The timeout duration to establishing the connection. |
| 72 | +| proxySelector | ProxySelector | ProxySelector.getDefault() | The proxy selector used by HTTP Client. |
| 73 | +| executor | Executor | Thread Pool of size 5 | The executor used by HTTP Client. |
| 74 | + |
0 commit comments