Skip to content

Option to filter variants by matching ALL overrides, not only ANY #32

@samuelneff

Description

@samuelneff

Describe the feature request

We would like to create some complex scenarios that require filtering variants based on multiple overrides matching, not based on any one of multiple overrides matching.

Background

Significantly more detail and background available in previous discussion: https://github.com/orgs/Unleash/discussions/3224.

Solution suggestions

Default behavior could remain the same of course, but an option in the SDK to specify either per-call, per flag, or per-client that variant overrides should be implemented such that all must match.

/*
    Feature flag `allocation-policy` configured with these variants and overrides:

Name                    Overrides                           Value 
------------------      ------------------------------      ----------------
default                 *none*                              never
corp                    office=corp                         lowest-load
boston                  office=boston                       round-robin
boston-managers         office=boston, role=manager         never
    Then we can expect this kind of result with the provided overrides:
*/
val unleash = Unleash.....overrideMatchingPolicy(OverrideMatchingPolicy.MATCH_ALL)

unleash.getVariant(
    "allocation-policy",
    mapOf("office" to "boston")
)

    // Result: `round-robin`, it matched override `boston` but not `manager`,
    // so `never` is not a valid option here


unleash.getVariant(
    "allocation-policy",
    mapOf(
        "office" to "boston",
        "role" to "manager"
    )
)

    // Result: `never`, it matches both overrides `boston` and `manager`,
    // so it will always return `never`


unleash.getVariant("allocation-policy")

    // Result: `lowest-load`, no overrides matched / provided

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions