Skip to content

Commit

Permalink
feat: allow custom seed in fractional op (#136)
Browse files Browse the repository at this point in the history
<!-- Please use this template for your pull request. -->
<!-- Please use the sections that you need and delete other sections -->

## This PR
<!-- add the description of the PR here -->

- updates fractional schema to accept complex rules as first argument to
override targeting so that we can support using `cat` and other rules to
provide custom seeds to randomisation

### Related Issues
<!-- add here the GitHub issue that this PR resolves if applicable -->

open-feature/flagd#1264
resolves open-feature/flagd#1265

### Notes
<!-- any additional notes for this PR -->

### Follow-up Tasks
<!-- anything that is related to this PR but not done here should be
noted under this section -->
<!-- if there is a need for a new issue, please link it here -->

### How to test
<!-- if applicable, add testing instructions under this section -->

see open-feature/flagd#1266

---------

Signed-off-by: Cole Bailey <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Co-authored-by: Kavindu Dodanduwa <[email protected]>
  • Loading branch information
colebaileygit and Kavindu-Dodan authored Apr 8, 2024
1 parent b471b40 commit ea4f119
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ permissions:
contents: read

env:
GO_VERSION: 1.20.7
GO_VERSION: 1.22

jobs:
lint-protos:
Expand Down
2 changes: 1 addition & 1 deletion json/targeting.json
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@
"items": [
{
"description": "Bucketing value used in pseudorandom assignment; should be unique and stable for each subject of flag evaluation. Defaults to a concatenation of the flagKey and targetingKey.",
"$ref": "#/$defs/varRule"
"$ref": "#/$defs/anyRule"
},
{
"$ref": "#/$defs/fractionalWeightArg"
Expand Down
2 changes: 1 addition & 1 deletion json/targeting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ type: object
- description: Bucketing value used in pseudorandom assignment; should be unique
and stable for each subject of flag evaluation. Defaults to a concatenation
of the flagKey and targetingKey.
$ref: "#/$defs/varRule"
$ref: "#/$defs/anyRule"
- $ref: "#/$defs/fractionalWeightArg"
- $ref: "#/$defs/fractionalWeightArg"
additionalItems:
Expand Down
5 changes: 4 additions & 1 deletion json/test/positive/custom-ops.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
"defaultVariant": "wild",
"targeting": {
"fractional": [
{ "var": "user.name" },
{ "cat": [
{ "var": "$flagd.flagKey" },
{ "var": "user.name" }
]},
["clubs", 25],
["diamonds", 25],
["hearts", 25],
Expand Down

0 comments on commit ea4f119

Please sign in to comment.