Question
How to implement a feature from Split based on certain scheduled time? Meaning ability to switch from 'on' to 'off' automatically at a certain time?
Answer
There are two ways to accomplish this:
-
Using the Admin REST API to change feature flag definitions and rules, for example, you can create the banner feature flag, set the default rule to on, then use the Admin API to change the default to off. You can run the Admin API using curl and it's possible to use any host OS scheduler to schedule the curl command to run at a specific date-time.
curl command example:
curl -v -X PATCH -d '[{"op": "replace", "path": "/defaultRule", "value":[ { "treatment": "on", "size": 100 } ]}]' -H 'Content-Type:application/json' -H 'Authorization: Bearer [ADMIN API KEY]' https://api.split.io/internal/api/v2/splits/ws/[WORKSPACE ID]/[SPLIT NAME]/environments/Production
- You can also use a targeting rule and pass the system time to change a flag. You can turn it on or off at a specific time, for a subset of users or for all users. Or, you can turn it on in a window of time. For example, if you want to turn a message on alerting users during a maintenance window you might set up the rule as shown in the attached screenshot.
Comments
1 comment
Screenshot is missing here, I am looking for second bullet point
Please sign in to leave a comment.