Skip to content

Commit

Permalink
feat(OFREP): Add cacheable metadata (#2163)
Browse files Browse the repository at this point in the history
* feat(OFREP): Add cacheable metadata

Signed-off-by: Thomas Poignant <thomas.poignant@gofeatureflag.org>

* fix test

Signed-off-by: Thomas Poignant <thomas.poignant@gofeatureflag.org>

---------

Signed-off-by: Thomas Poignant <thomas.poignant@gofeatureflag.org>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
thomaspoignant and kodiakhq[bot] authored Jul 30, 2024
1 parent f797c69 commit 6627a64
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
10 changes: 9 additions & 1 deletion cmd/relayproxy/ofrep/evaluate.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,20 @@ func (h *EvaluateCtrl) Evaluate(c echo.Context) error {
attribute.String("flagEvaluation.value", fmt.Sprintf("%v", flagValue.Value)),
)

metadata := flagValue.Metadata
if flagValue.Cacheable {
if metadata == nil {
metadata = make(map[string]interface{})
}
metadata["gofeatureflag_cacheable"] = true
}

return c.JSON(http.StatusOK, model.OFREPEvaluateSuccessResponse{
Key: flagKey,
Value: flagValue.Value,
Reason: flagValue.Reason,
Variant: flagValue.VariationType,
Metadata: flagValue.Metadata,
Metadata: metadata,
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
"key": "number-flag",
"value": 1,
"reason": "DEFAULT",
"variant": "Default"
"variant": "Default",
"metadata": {
"gofeatureflag_cacheable": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
"key": "targeting-key-rule",
"value": true,
"reason": "TARGETING_MATCH",
"variant": "true_var"
"variant": "true_var",
"metadata": {
"gofeatureflag_cacheable": true
}
}

0 comments on commit 6627a64

Please sign in to comment.