Skip to content

Commit 5e6f4a1

Browse files
authored
feat: ISSUE-658 go-feature-flag sdk - add cache (#369)
1 parent b571cc5 commit 5e6f4a1

File tree

16 files changed

+825
-87
lines changed

16 files changed

+825
-87
lines changed

providers/go-feature-flag/README.md

+15-8
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,34 @@ GO Feature Flag provider allows you to connect to your [GO Feature Flag relay pr
44

55
## How to use this provider?
66

7-
To initialize your instance please follow this example:
7+
To use your instance please follow this example:
88

99
```java
1010
import dev.openfeature.contrib.providers.gofeatureflag;
1111

1212
// ...
13-
new GoFeatureFlagProvider(
13+
FeatureProvider provider = new GoFeatureFlagProvider(
1414
GoFeatureFlagProviderOptions
1515
.builder()
1616
.endpoint("https://my-gofeatureflag-instance.org")
1717
.timeout(1000)
1818
.build());
19+
// ...
20+
provider.shutdown();
1921
```
2022

2123
You will have a new instance ready to be used with your `open-feature` java SDK.
2224

2325
### Options
2426

25-
| name | mandatory | Description |
26-
|--------------------------|-----------|----------------------------------------------------------------------------------------------------------------|
27-
| **`endpoint`** | `true` | endpoint contains the DNS of your GO Feature Flag relay proxy _(ex: https://mydomain.com/gofeatureflagproxy/)_ |
28-
| **`timeout`** | `false` | timeout in millisecond we are waiting when calling the go-feature-flag relay proxy API. _(default: 10000)_ |
29-
| **`maxIdleConnections`** | `false` | maxIdleConnections is the maximum number of connexions in the connexion pool. _(default: 1000)_ |
30-
| **`keepAliveDuration`** | `false` | keepAliveDuration is the time in millisecond we keep the connexion open. _(default: 7200000 (2 hours))_ |
27+
| name | mandatory | Description |
28+
|--------------------------|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
29+
| **`endpoint`** | `true` | endpoint contains the DNS of your GO Feature Flag relay proxy _(ex: https://mydomain.com/gofeatureflagproxy/)_ |
30+
| **`timeout`** | `false` | timeout in millisecond we are waiting when calling the go-feature-flag relay proxy API. _(default: 10000)_ |
31+
| **`maxIdleConnections`** | `false` | maxIdleConnections is the maximum number of connexions in the connexion pool. _(default: 1000)_ |
32+
| **`keepAliveDuration`** | `false` | keepAliveDuration is the time in millisecond we keep the connexion open. _(default: 7200000 (2 hours))_ |
33+
| **`apiKey`** | `false` | If the relay proxy is configured to authenticate the requests, you should provide an API Key to the provider. Please ask the administrator of the relay proxy to provide an API Key. (This feature is available only if you are using GO Feature Flag relay proxy v1.7.0 or above). _(default: null)_ |
34+
| **`enableCache`** | `false` | enable cache value. _(default: true)_ |
35+
| **`cacheBuilder`** | `false` | If cache custom configuration is wanted, you should provide a cache builder. _(default: null)_ |
36+
| **`flushIntervalMs`** | `false` | interval time we publish statistics collection data to the proxy. The parameter is used only if the cache is enabled, otherwise the collection of the data is done directly when calling the evaluation API. _(default: 1000 ms)_ |
37+
| **`maxPendingEvents`** | `false` | max pending events aggregated before publishing for collection data to the proxy. When event is added while events collection is full, event is omitted. _(default: 10000)_ |

providers/go-feature-flag/pom.xml

+20
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,25 @@
5050
<version>4.11.0</version>
5151
<scope>test</scope>
5252
</dependency>
53+
54+
<dependency>
55+
<groupId>com.google.guava</groupId>
56+
<artifactId>guava</artifactId>
57+
<version>32.1.1-jre</version>
58+
</dependency>
59+
60+
<dependency>
61+
<groupId>org.slf4j</groupId>
62+
<artifactId>slf4j-api</artifactId>
63+
<version>2.0.7</version>
64+
</dependency>
65+
66+
<dependency>
67+
<groupId>org.apache.logging.log4j</groupId>
68+
<artifactId>log4j-slf4j2-impl</artifactId>
69+
<version>2.20.0</version>
70+
<scope>test</scope>
71+
</dependency>
72+
5373
</dependencies>
5474
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package dev.openfeature.contrib.providers.gofeatureflag;
2+
3+
import dev.openfeature.sdk.ProviderEvaluation;
4+
import lombok.Builder;
5+
import lombok.Getter;
6+
7+
/**
8+
* EvaluationResponse wrapping the provider evaluation.
9+
* @param <T> evaluation type
10+
*/
11+
@Builder
12+
@Getter
13+
public class EvaluationResponse<T> {
14+
private ProviderEvaluation<T> providerEvaluation;
15+
private Boolean cachable;
16+
}

0 commit comments

Comments
 (0)