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

Add support for Aggregate strategies #102

Closed
ivarconr opened this issue Aug 21, 2015 · 4 comments
Closed

Add support for Aggregate strategies #102

ivarconr opened this issue Aug 21, 2015 · 4 comments

Comments

@ivarconr
Copy link
Member

After using unleash for a while we see that we now have a lot of "aggregate strategies" implemented, such as "usersWithIdAndBetaUsers" etc.

Instead of having all different combinations of strategies implemented in all clients we could provide a way to define aggregated strategies. This way we only need the simple strategies implemented in each client.

@ivarconr
Copy link
Member Author

ivarconr commented Aug 24, 2015

The filter-pattern approach

A simple way to solve this is extend the current API with a strategies field. The current strategy and parameters field would be deprecated in favour of a new strategies array containing all strategies associated with a feature toggles. The idea is that any toggle can be associated with one or more strategies. If the toggle is enabled with any of the associated strategies it should be considered on.

The suggested solution allows us to keep strategies simple and at the same time add multiple strategies to any toggle without having to implement all possible combinations upfront in all clients.

Current format:

{
    "features": [
        {
            "name": "featureX",
            "description": "",
            "enabled": true,
            "strategy": "default",
            "parameters": {}
        },
        {
            "name": "featureY",
            "description": "",
            "enabled": true,
            "strategy": "ActiveForUserWithEmail",
            "parameters": {
                "emails": "[email protected]"
            }
        }
    ]
}

_New API_

{
    "version": 1,
    "features": [
        {
            "name": "featureX",
            "description": "",
            "enabled": true,
            "strategy": "default", //kept for backward compability
            "parameters": {}, //kept for backward compability
            "strategies": [
                {
                    "name": "some_strategy",
                    "parameters": {}
                }
            ]
        },
        {
            "name": "featureY",
            "description": "",
            "enabled": true,
            "strategy": "default",
            "parameters": {},
            "strategies": [
                {
                    "name": "some_strategy",
                    "parameters": {
                        "emails": "[email protected]"
                    }
                }
            ]
        }
    ]
}

@sveinelo
Copy link

+1

Could "strategy" be dropped from the new API?

@ivarconr
Copy link
Member Author

yes. But that should be a two-step iteration:

  • iteration 1: introduce new field, and deprecate old one.
  • iteration 2: remove the old field (not backward compatible).

@ivarconr
Copy link
Member Author

ivarconr commented Apr 27, 2016

we have decided to move forward with multiple strategies. Based on real-world usage of Unleash we feel the need ability to add multiple activation strategies for a feature toggle. To make it simple to understand and easy to use (and based on what people actually have asked for) all strategies should be OR from the client perspective, meaning that if a feature toggle is considered active with one strategy it should be considered enabled.

TODO:

  • Add support for the new format in API
    • migrations for the database to new schema (also copy strategy-config)
    • run a few test against real production-data to make sure the validations works
    • document the new db-schema
    • add mapping for legacyProperties to support old clients. We should just expose the first strategyConfig in the list of strategies for a toggle.
    • implement validations that user does not POST old props (strategy, parameters) and the new prop (strategies) at the same time.
    • clean up the api-tests.
    • document the new API-format
    • Add version property to the new API-format to ease deserialization in clients.
  • Add support for multiple strategies in the Admin UI
  • Add support for multiple strategies in the clients.

@Andersos Andersos added this to the 2.0 milestone Apr 27, 2016
ivarconr added a commit that referenced this issue Jun 18, 2016
ivarconr added a commit that referenced this issue Jul 2, 2016
This commit changes the features-tables:
- drop columns 'strategy' and 'parameters'
- add column 'strategies' of type json.
- migrates existing strategy-mappings in to the new format.

The idea is that the 'strategies' column should contain a json-array
of strategy-configuration for the toggle:

```
[{
 "name" : "strategy1",
 "parameters": { "name": "vale" }
}]

```

To make sure to not break exiting clients the api is extended with a
mapping layer (adding old fields to the json-respons, and mapping
to the new format on create/update a feature toggle.

this commit is first step in solving #102
ivarconr added a commit that referenced this issue Jul 2, 2016
This commit changes the features-tables:
- drop columns 'strategy' and 'parameters'
- add column 'strategies' of type json.
- migrates existing strategy-mappings in to the new format.

The idea is that the 'strategies' column should contain a json-array
of strategy-configuration for the toggle:

```
[{
 "name" : "strategy1",
 "parameters": { "name": "vale" }
}]

```

To make sure to not break exiting clients the api is extended with a
mapping layer (adding old fields to the json-respons, and mapping
to the new format on create/update a feature toggle.

this commit is first step in solving #102
ivarconr added a commit that referenced this issue Aug 22, 2016
This commit changes the features-tables:
- drop columns 'strategy' and 'parameters'
- add column 'strategies' of type json.
- migrates existing strategy-mappings in to the new format.

The idea is that the 'strategies' column should contain a json-array
of strategy-configuration for the toggle:

```
[{
 "name" : "strategy1",
 "parameters": { "name": "vale" }
}]

```

To make sure to not break exiting clients the api is extended with a
mapping layer (adding old fields to the json-respons, and mapping
to the new format on create/update a feature toggle.

this commit is first step in solving #102
ivarconr added a commit that referenced this issue Sep 5, 2016
This commit changes the features-tables:
- drop columns 'strategy' and 'parameters'
- add column 'strategies' of type json.
- migrates existing strategy-mappings in to the new format.

The idea is that the 'strategies' column should contain a json-array
of strategy-configuration for the toggle:

```
[{
 "name" : "strategy1",
 "parameters": { "name": "vale" }
}]

```

To make sure to not break exiting clients the api is extended with a
mapping layer (adding old fields to the json-respons, and mapping
to the new format on create/update a feature toggle.

this commit is first step in solving #102
ivarconr added a commit that referenced this issue Sep 6, 2016
ivarconr added a commit that referenced this issue Sep 6, 2016
This commit changes the features-tables:
- drop columns 'strategy' and 'parameters'
- add column 'strategies' of type json.
- migrates existing strategy-mappings in to the new format.

The idea is that the 'strategies' column should contain a json-array
of strategy-configuration for the toggle:

```
[{
 "name" : "strategy1",
 "parameters": { "name": "vale" }
}]

```

To make sure to not break exiting clients the api is extended with a
mapping layer (adding old fields to the json-respons, and mapping
to the new format on create/update a feature toggle.

this commit is first step in solving #102
ivarconr added a commit that referenced this issue Sep 6, 2016
ivarconr added a commit that referenced this issue Sep 6, 2016
ivarconr added a commit that referenced this issue Sep 6, 2016
ivarconr pushed a commit that referenced this issue Sep 6, 2016
ivarconr added a commit that referenced this issue Sep 6, 2016
ivarconr added a commit that referenced this issue Sep 6, 2016
ivarconr added a commit that referenced this issue Sep 7, 2016
ivarconr added a commit that referenced this issue Sep 7, 2016
@ivarconr ivarconr mentioned this issue Sep 13, 2016
23 tasks
@ivarconr ivarconr closed this as completed Nov 5, 2016
ivarconr added a commit that referenced this issue Feb 20, 2020
This commit changes the features-tables:
- drop columns 'strategy' and 'parameters'
- add column 'strategies' of type json.
- migrates existing strategy-mappings in to the new format.

The idea is that the 'strategies' column should contain a json-array
of strategy-configuration for the toggle:

```
[{
 "name" : "strategy1",
 "parameters": { "name": "vale" }
}]

```

To make sure to not break exiting clients the api is extended with a
mapping layer (adding old fields to the json-respons, and mapping
to the new format on create/update a feature toggle.

this commit is first step in solving #102
ivarconr added a commit that referenced this issue Feb 20, 2020
ivarconr added a commit that referenced this issue Feb 20, 2020
ivarconr added a commit that referenced this issue Feb 20, 2020
ivarconr pushed a commit that referenced this issue Feb 20, 2020
ivarconr added a commit that referenced this issue Feb 20, 2020
ivarconr added a commit that referenced this issue Feb 20, 2020
ivarconr added a commit that referenced this issue Feb 20, 2020
ivarconr added a commit that referenced this issue Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants