Skip to content

[FEATURE] selector param/header for OFREP #1611

@toddbaert

Description

@toddbaert

flagd supports selectors, so separate flags into different buckets, eg. each file source, http source, etc, is its own selector.
If flagd is started with multiple sources, the selector param can be used to evaluate/sync only the set of flags from the source in question:

Example

a.json and
b.json:

{
    "flags": {
        "flagb": {
            "state": "ENABLED",
            "variants": {
                "foo": "foo",
                "bar": "bar"
            },
            "defaultVariant": "foo"
        }
    },
    "metadata": {
        "flagSetId": "b"
    }
}
{
    "flags": {
        "flaga": {
            "state": "ENABLED",
            "variants": {
                "foo": "foo",
                "bar": "bar"
            },
            "defaultVariant": "foo"
        }
    },
    "metadata": {
        "flagSetId": "a"
    }
}

start flagd with those two files as sources:

docker run \
  --rm -it \
  --name flagd \
  -p 8015:8015 \
  -v $(pwd):/flags \
  ghcr.io/open-feature/flagd:latest start \
  --uri file:./flags/a.json \
  --uri file:./flags/b.json

then, you can use:

curl -X POST 'http://localhost:8016/ofrep/v1/evaluate/flags/flaga'

and

curl -X POST 'http://localhost:8016/ofrep/v1/evaluate/flags/flagb'

and

curl -X POST 'http://localhost:8016/ofrep/v1/evaluate/flags'

We want to support a "selector" field similar to what's in the sync protocol, as a header, which would restrict evaluations to only the flag set identified by the header. ie:

curl -H 'X-Flag-Set-Id:a' -X POST 'http://localhost:8016/ofrep/v1/evaluate/flagb' // not found since flagb is not in set a.

Note, this requires #1610 to be done first.

The precise name of the header is subject to discussion, but feel free to make a proposal or use what I've suggested above.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions