-
-
Notifications
You must be signed in to change notification settings - Fork 686
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add new Flexible Rollout Strategy (#517)
* feat: Add new Flexible Rollout Strategy fixes #516 * feat: update unleash-frontend to version 3.2.8 * chore: update flexible rollout documentation
- Loading branch information
Showing
5 changed files
with
107 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
'use strict'; | ||
|
||
const flexibleRollout = require('./flexible-rollout-strategy.json'); | ||
const async = require('async'); | ||
|
||
function insertStrategySQL(strategy) { | ||
return ` | ||
INSERT INTO strategies (name, description, parameters, built_in) | ||
SELECT '${strategy.name}', '${strategy.description}', '${JSON.stringify( | ||
strategy.parameters | ||
)}', 1 | ||
WHERE | ||
NOT EXISTS ( | ||
SELECT name FROM strategies WHERE name = '${strategy.name}' | ||
);`; | ||
} | ||
|
||
function insertEventsSQL(strategy) { | ||
return ` | ||
INSERT INTO events (type, created_by, data) | ||
SELECT 'strategy-created', 'migration', '${JSON.stringify(strategy)}' | ||
WHERE | ||
NOT EXISTS ( | ||
SELECT name FROM strategies WHERE name = '${strategy.name}' | ||
);`; | ||
} | ||
|
||
function removeEventsSQL(strategy) { | ||
return ` | ||
INSERT INTO events (type, created_by, data) | ||
SELECT 'strategy-deleted', 'migration', '${JSON.stringify(strategy)}' | ||
WHERE | ||
EXISTS ( | ||
SELECT name FROM strategies WHERE name = '${ | ||
strategy.name | ||
}' AND built_in = 1 | ||
);`; | ||
} | ||
|
||
function removeStrategySQL(strategy) { | ||
return ` | ||
DELETE FROM strategies | ||
WHERE name = '${strategy.name}' AND built_in = 1`; | ||
} | ||
|
||
exports.up = function(db, callback) { | ||
async.series( | ||
[ | ||
db.runSql.bind(db, insertEventsSQL(flexibleRollout)), | ||
db.runSql.bind(db, insertStrategySQL(flexibleRollout)), | ||
], | ||
callback | ||
); | ||
}; | ||
|
||
exports.down = function(db, callback) { | ||
async.series( | ||
[ | ||
db.runSql.bind(db, removeEventsSQL(flexibleRollout)), | ||
db.runSql.bind(db, removeStrategySQL(flexibleRollout)), | ||
], | ||
callback | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "flexibleRollout", | ||
"description": "Gradually activate feature toggle based on sane stickiness", | ||
"parameters": [ | ||
{ | ||
"name": "rollout", | ||
"type": "percentage", | ||
"description": "", | ||
"required": false | ||
}, | ||
{ | ||
"name": "stickiness", | ||
"type": "string", | ||
"description": "Used define stickiness. Possible values: default, userId, sessionId, random", | ||
"required": true | ||
}, | ||
{ | ||
"name": "groupId", | ||
"type": "string", | ||
"description": "Used to define a activation groups, which allows you to correlate across feature toggles.", | ||
"required": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters