You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(kotlin-provider): Support flag metadata (#2862)
* feat(kotlin-provider): Support flag metadata
Signed-off-by: Thomas Poignant <[email protected]>
* Update doc
Signed-off-by: Thomas Poignant <[email protected]>
---------
Signed-off-by: Thomas Poignant <[email protected]>
| β | Flag evaluation | It is possible to evaluate all the type of flags |
160
+
| β | Cache invalidation |A polling mechanism is in place to refresh the cache in case of configuration change|
161
+
| β | Logging | Not supported by the SDK |
162
+
|β | Flag Metadata |You have access to your flag metadata |
163
+
| β | Event Streaming |You can register to receive some internal event from the provider |
164
+
| β | Unit test |The test are running one by one, but we still have an [issue open](https://github.com/open-feature/kotlin-sdk/issues/108) to enable fully the tests|
Copy file name to clipboardexpand all lines: openfeature/providers/kotlin-provider/gofeatureflag-kotlin-provider/src/main/java/org/gofeatureflag/openfeature/ofrep/OfrepProvider.kt
Copy file name to clipboardexpand all lines: openfeature/providers/kotlin-provider/gofeatureflag-kotlin-provider/src/main/java/org/gofeatureflag/openfeature/ofrep/bean/OfrepApiResponse.kt
+46-5
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,4 @@
1
+
importdev.openfeature.sdk.EvaluationMetadata
1
2
importdev.openfeature.sdk.ProviderEvaluation
2
3
importdev.openfeature.sdk.Value
3
4
importdev.openfeature.sdk.exceptions.ErrorCode
@@ -16,7 +17,8 @@ data class FlagDto(
16
17
valreason:String,
17
18
valvariant:String,
18
19
valerrorCode:ErrorCode?,
19
-
valerrorDetails:String?
20
+
valerrorDetails:String?,
21
+
valmetadata:Map<String, Any>? = emptyMap()
20
22
) {
21
23
funisError(): Boolean {
22
24
return errorCode !=null
@@ -38,7 +40,8 @@ data class FlagDto(
38
40
reason = reason,
39
41
variant = variant,
40
42
errorCode = errorCode,
41
-
errorMessage = errorDetails
43
+
errorMessage = errorDetails,
44
+
metadata = convertMetadata(metadata)
42
45
)
43
46
}
44
47
@@ -50,7 +53,8 @@ data class FlagDto(
50
53
reason = reason,
51
54
variant = variant,
52
55
errorCode = errorCode,
53
-
errorMessage = errorDetails
56
+
errorMessage = errorDetails,
57
+
metadata = convertMetadata(metadata)
54
58
)
55
59
} elseif (value isMap<*, *>) {
56
60
val typedValue = convertObjectToStructure(value)
@@ -59,7 +63,8 @@ data class FlagDto(
59
63
reason = reason,
60
64
variant = variant,
61
65
errorCode = errorCode,
62
-
errorMessage = errorDetails
66
+
errorMessage = errorDetails,
67
+
metadata = convertMetadata(metadata)
63
68
)
64
69
} else {
65
70
throwIllegalArgumentException("Unsupported type for: $value")
Copy file name to clipboardexpand all lines: openfeature/providers/kotlin-provider/gofeatureflag-kotlin-provider/src/test/java/org/gofeatureflag/openfeature/ofrep/OfrepProviderTest.kt
+37-2
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
packageorg.gofeatureflag.openfeature.ofrep
2
2
3
3
importdev.openfeature.sdk.EvaluationContext
4
+
importdev.openfeature.sdk.EvaluationMetadata
4
5
importdev.openfeature.sdk.FlagEvaluationDetails
5
6
importdev.openfeature.sdk.ImmutableContext
6
7
importdev.openfeature.sdk.OpenFeatureAPI
@@ -230,6 +231,10 @@ class OfrepProviderTest {
230
231
reason ="DEFAULT",
231
232
errorCode =null,
232
233
errorMessage =null,
234
+
metadata =EvaluationMetadata.builder()
235
+
.putString("description", "This flag controls the title of the feature flag")
236
+
.putString("title", "Feature Flag Title")
237
+
.build()
233
238
)
234
239
assertEquals(want, got)
235
240
}
@@ -312,7 +317,7 @@ class OfrepProviderTest {
312
317
}
313
318
314
319
@Test
315
-
fun`should return a valid evaluation for Boolean`() = runBlocking {
320
+
fun`should return a valid evaluation for Boolean`(): Unit= runBlocking {
Copy file name to clipboardexpand all lines: openfeature/providers/kotlin-provider/gofeatureflag-kotlin-provider/src/test/java/org/gofeatureflag/openfeature/ofrep/controller/OfrepApiTest.kt
+10-3
Original file line number
Diff line number
Diff line change
@@ -59,6 +59,7 @@ class OfrepApiTest {
59
59
)
60
60
val res = ofrepApi.postBulkEvaluateFlags(ctx)
61
61
assertEquals(200, res.httpResponse.code)
62
+
62
63
val expected =OfrepApiResponse(
63
64
flags =listOf(
64
65
FlagDto(
@@ -67,23 +68,29 @@ class OfrepApiTest {
67
68
reason ="DEFAULT",
68
69
variant ="nocolor",
69
70
errorCode =null,
70
-
errorDetails =null
71
+
errorDetails =null,
72
+
metadata =null
71
73
),
72
74
FlagDto(
73
75
key ="hide-logo",
74
76
value =false,
75
77
reason ="STATIC",
76
78
variant ="var_false",
77
79
errorCode =null,
78
-
errorDetails =null
80
+
errorDetails =null,
81
+
metadata =null
79
82
),
80
83
FlagDto(
81
84
key ="title-flag",
82
85
value ="GO Feature Flag",
83
86
reason ="DEFAULT",
84
87
variant ="default_title",
85
88
errorCode =null,
86
-
errorDetails =null
89
+
errorDetails =null,
90
+
metadata = hashMapOf<String, Any>(
91
+
"description" to "This flag controls the title of the feature flag",
| β | Flag evaluation | It is possible to evaluate all the type of flags |
204
+
| β | Cache invalidation | A polling mechanism is in place to refresh the cache in case of configuration change |
205
+
| β | Logging | Not supported by the SDK |
206
+
| β | Flag Metadata | You have access to your flag metadata |
207
+
| β | Event Streaming | You can register to receive some internal event from the provider |
208
+
| β | Unit test | The test are running one by one, but we still have an [issue open](https://github.com/open-feature/kotlin-sdk/issues/108) to enable fully the tests |
0 commit comments