Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow custom seed in fractional op #136

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 1 addition & 35 deletions 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 All @@ -506,37 +506,6 @@
"$ref": "#/$defs/fractionalWeightArg"
}
},
"fractionalCustomSeedOp": {
"type": "array",
"minItems": 4,
"$comment": "there seems to be a bug here, where ajv gives a warning (not an error) because maxItems doesn't equal the number of entries in items, though this is valid in this case",
"items": [
{
"description": "Bucketing value used in pseudorandom assignment; should be unique and stable for each subject of flag evaluation. Defaults to targetingKey.",
"$ref": "#/$defs/varRule"
},
{
"description": "Seed used in pseudorandom assignment. Defaults to flagKey.",
"anyOf": [
{
"$ref": "#/$defs/varRule"
},
{
"type": "string"
}
]
},
{
"$ref": "#/$defs/fractionalWeightArg"
},
{
"$ref": "#/$defs/fractionalWeightArg"
}
],
"additionalItems": {
"$ref": "#/$defs/fractionalWeightArg"
}
},
"fractionalRule": {
"type": "object",
"additionalProperties": false,
Expand All @@ -545,9 +514,6 @@
"title": "Fractional Operation",
"description": "Deterministic, pseudorandom fractional distribution.",
"oneOf": [
{
"$ref": "#/$defs/fractionalCustomSeedOp"
},
{
"$ref": "#/$defs/fractionalOp"
},
Expand Down
19 changes: 1 addition & 18 deletions 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"
beeme1mr marked this conversation as resolved.
Show resolved Hide resolved
- $ref: "#/$defs/fractionalWeightArg"
- $ref: "#/$defs/fractionalWeightArg"
additionalItems:
Expand All @@ -399,22 +399,6 @@ type: object
minItems: 2
items:
$ref: "#/$defs/fractionalWeightArg"
fractionalCustomSeedOp:
type: array
minItems: 4
$comment: there seems to be a bug here, where ajv gives a warning (not an error) because maxItems doesn't equal the number of entries in items, though this is valid in this case
items:
- description: Bucketing value used in pseudorandom assignment; should be unique
and stable for each subject of flag evaluation. Defaults to targetingKey.
$ref: "#/$defs/varRule"
- description: Seed used in pseudorandom assignment. Defaults to flagKey.
anyOf:
- $ref: "#/$defs/varRule"
- type: string
- $ref: "#/$defs/fractionalWeightArg"
- $ref: "#/$defs/fractionalWeightArg"
additionalItems:
$ref: "#/$defs/fractionalWeightArg"
fractionalRule:
type: object
additionalProperties: false
Expand All @@ -423,7 +407,6 @@ type: object
title: Fractional Operation
description: Deterministic, pseudorandom fractional distribution.
oneOf:
- $ref: "#/$defs/fractionalCustomSeedOp"
- $ref: "#/$defs/fractionalOp"
- $ref: "#/$defs/fractionalShorthandOp"
reference:
Expand Down
26 changes: 4 additions & 22 deletions 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 All @@ -41,27 +44,6 @@
]
}
},
"custom-seed-fractional-flag": {
"state": "ENABLED",
"variants": {
"clubs": "clubs",
"diamonds": "diamonds",
"hearts": "hearts",
"spades": "spades",
"wild": "wild"
},
"defaultVariant": "wild",
"targeting": {
"fractional": [
{ "var": "user.name" },
"my-seed",
["clubs", 25],
["diamonds", 25],
["hearts", 25],
["spades", 25]
]
}
},
"starts-ends-flag": {
"state": "ENABLED",
"variants": {
Expand Down
Loading