Skip to content

Commit 694ee51

Browse files
committed
updates
Signed-off-by: liran2000 <[email protected]>
1 parent bedc394 commit 694ee51

File tree

3 files changed

+213
-36
lines changed

3 files changed

+213
-36
lines changed
Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1 @@
11
# Changelog
2-
3-
## [0.1.2](https://github.com/open-feature/java-sdk-contrib/compare/dev.openfeature.contrib.tools.junitopenfeature-v0.1.1...dev.openfeature.contrib.tools.junitopenfeature-v0.1.2) (2024-12-03)
4-
5-
6-
### ✨ New Features
7-
8-
* added interception of parameterized tests to Junit OpenFeature Extension ([#1093](https://github.com/open-feature/java-sdk-contrib/issues/1093)) ([a78c906](https://github.com/open-feature/java-sdk-contrib/commit/a78c906b24b53f7d25eb01aad85ed614eb30ca05))
9-
10-
## [0.1.1](https://github.com/open-feature/java-sdk-contrib/compare/dev.openfeature.contrib.tools.junitopenfeature-v0.1.0...dev.openfeature.contrib.tools.junitopenfeature-v0.1.1) (2024-09-27)
11-
12-
13-
### 🐛 Bug Fixes
14-
15-
* race condition causing default when multiple flags are used ([#983](https://github.com/open-feature/java-sdk-contrib/issues/983)) ([356a973](https://github.com/open-feature/java-sdk-contrib/commit/356a973cf2b6ddf82b8311ea200fa30df4f1d048))
16-
17-
## [0.1.0](https://github.com/open-feature/java-sdk-contrib/compare/dev.openfeature.contrib.tools.junitopenfeature-v0.0.3...dev.openfeature.contrib.tools.junitopenfeature-v0.1.0) (2024-09-25)
18-
19-
20-
### 🐛 Bug Fixes
21-
22-
* **deps:** update dependency org.apache.commons:commons-lang3 to v3.17.0 ([#932](https://github.com/open-feature/java-sdk-contrib/issues/932)) ([c598d9f](https://github.com/open-feature/java-sdk-contrib/commit/c598d9f0a61f2324fb85d72fdfea34811283c575))
23-
24-
25-
### 🐛 Bug Fixes
26-
27-
* added missing dependency and installation instruction ([#895](https://github.com/open-feature/java-sdk-contrib/issues/895)) ([6748d02](https://github.com/open-feature/java-sdk-contrib/commit/6748d02403f0ceecb6cb9ecdfb2fecf98423a7db))
28-
* **deps:** update dependency org.apache.commons:commons-lang3 to v3.16.0 ([#908](https://github.com/open-feature/java-sdk-contrib/issues/908)) ([d21cfe3](https://github.com/open-feature/java-sdk-contrib/commit/d21cfe3ac7da1ff6e1a4dc2ee4b0db5c24ed4847))
29-
30-
## [0.0.2](https://github.com/open-feature/java-sdk-contrib/compare/dev.openfeature.contrib.tools.junitopenfeature-v0.0.1...dev.openfeature.contrib.tools.junitopenfeature-v0.0.2) (2024-07-29)
31-
32-
33-
### ✨ New Features
34-
35-
* Add JUnit5 extension for OpenFeature ([#888](https://github.com/open-feature/java-sdk-contrib/issues/888)) ([9fff9db](https://github.com/open-feature/java-sdk-contrib/commit/9fff9db4bcee3c3ae8128a1b2fb040f53df1d5ed))

tools/flagd-http-connector/README.md

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,27 @@ URL, effectively acting as a flagd/proxy while all other services leverage the s
3636
This approach optimizes resource usage by preventing redundant polling across services.
3737

3838
### Sample flow demonstrating the architecture
39-
This example demonstrates an architectural flow using:
39+
40+
#### Basic Simple Configuration
41+
42+
This example demonstrates a simple flow using:
43+
- GitHub as the source for flag payload.
44+
45+
```mermaid
46+
sequenceDiagram
47+
participant service
48+
participant Github
49+
50+
service->>Github: fetch
51+
Github->>service: payload
52+
Note right of service: polling interval passed
53+
service->>Github: fetch
54+
Github->>service: payload
55+
```
56+
57+
#### Configuration with fail-safe cache and polling cache
58+
59+
This example demonstrates a micro-services architectural flow using:
4060
- GitHub as the source for flag payload.
4161
- Redis serving as both the fail-safe initialization cache and the polling cache.
4262

@@ -85,7 +105,6 @@ sequenceDiagram
85105
### Usage example
86106

87107
```java
88-
89108
HttpConnectorOptions httpConnectorOptions = HttpConnectorOptions.builder()
90109
.url("http://example.com/flags")
91110
.build();
@@ -102,6 +121,42 @@ FlagdOptions options =
102121
FlagdProvider flagdProvider = new FlagdProvider(options);
103122
```
104123

124+
#### HttpConnector using fail-safe cache and polling cache
125+
126+
```java
127+
PayloadCache payloadCache = new PayloadCache() {
128+
129+
@Override
130+
public void put(String key, String payload) {
131+
// implement put in cache
132+
}
133+
134+
@Override
135+
public void put(String key, String payload, int ttlSeconds) {
136+
// implement put in cache with TTL
137+
}
138+
139+
@Override
140+
public String get(String key) {
141+
// implement get from cache and return
142+
}
143+
};
144+
145+
HttpConnectorOptions httpConnectorOptions = HttpConnectorOptions.builder()
146+
.url(testUrl)
147+
.useHttpCache(true)
148+
.payloadCache(payloadCache)
149+
.payloadCacheOptions(PayloadCacheOptions.builder().build())
150+
.useFailsafeCache(true)
151+
.pollIntervalSeconds(10)
152+
.usePollingCache(true)
153+
.build();
154+
155+
HttpConnector connector = HttpConnector.builder()
156+
.httpConnectorOptions(httpConnectorOptions)
157+
.build();
158+
```
159+
105160
### Configuration
106161
The Http Connector can be configured using the following properties in the `HttpConnectorOptions` class.:
107162

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
{
2+
"flags": {
3+
"boolean-flag": {
4+
"state": "ENABLED",
5+
"variants": {
6+
"on": true,
7+
"off": false
8+
},
9+
"defaultVariant": "on"
10+
},
11+
"string-flag": {
12+
"state": "ENABLED",
13+
"variants": {
14+
"greeting": "hi",
15+
"parting": "bye"
16+
},
17+
"defaultVariant": "greeting"
18+
},
19+
"integer-flag": {
20+
"state": "ENABLED",
21+
"variants": {
22+
"one": 1,
23+
"ten": 10
24+
},
25+
"defaultVariant": "ten"
26+
},
27+
"float-flag": {
28+
"state": "ENABLED",
29+
"variants": {
30+
"tenth": 0.1,
31+
"half": 0.5
32+
},
33+
"defaultVariant": "half"
34+
},
35+
"object-flag": {
36+
"state": "ENABLED",
37+
"variants": {
38+
"empty": {},
39+
"template": {
40+
"showImages": true,
41+
"title": "Check out these pics!",
42+
"imagesPerPage": 100
43+
}
44+
},
45+
"defaultVariant": "template"
46+
},
47+
"context-aware": {
48+
"state": "ENABLED",
49+
"variants": {
50+
"internal": "INTERNAL",
51+
"external": "EXTERNAL"
52+
},
53+
"defaultVariant": "external",
54+
"targeting": {
55+
"if": [
56+
{
57+
"and": [
58+
{
59+
"==": [
60+
{
61+
"var": [
62+
"fn"
63+
]
64+
},
65+
"Sulisław"
66+
]
67+
},
68+
{
69+
"==": [
70+
{
71+
"var": [
72+
"ln"
73+
]
74+
},
75+
"Świętopełk"
76+
]
77+
},
78+
{
79+
"==": [
80+
{
81+
"var": [
82+
"age"
83+
]
84+
},
85+
29
86+
]
87+
},
88+
{
89+
"==": [
90+
{
91+
"var": [
92+
"customer"
93+
]
94+
},
95+
false
96+
]
97+
}
98+
]
99+
},
100+
"internal",
101+
"external"
102+
]
103+
}
104+
},
105+
"timestamp-flag": {
106+
"state": "ENABLED",
107+
"variants": {
108+
"past": -1,
109+
"future": 1,
110+
"none": 0
111+
},
112+
"defaultVariant": "none",
113+
"targeting": {
114+
"if": [
115+
{
116+
">": [ { "var": "$flagd.timestamp" }, { "var": "time" } ]
117+
},
118+
"past",
119+
{
120+
"if": [
121+
{
122+
"<": [ { "var": "$flagd.timestamp" }, { "var": "time" } ]
123+
},
124+
"future", "none"
125+
]
126+
}
127+
]
128+
}
129+
},
130+
"wrong-flag": {
131+
"state": "ENABLED",
132+
"variants": {
133+
"one": "uno",
134+
"two": "dos"
135+
},
136+
"defaultVariant": "one"
137+
},
138+
"targeting-key-flag": {
139+
"state": "ENABLED",
140+
"variants": {
141+
"miss": "miss",
142+
"hit": "hit"
143+
},
144+
"defaultVariant": "miss",
145+
"targeting": {
146+
"if": [
147+
{
148+
"==": [ { "var": "targetingKey" }, "5c3d8535-f81a-4478-a6d3-afaa4d51199e" ]
149+
},
150+
"hit",
151+
null
152+
]
153+
}
154+
}
155+
}
156+
}

0 commit comments

Comments
 (0)