Reputation: 2076
I was looking at the documentation for UNLEASH feature toggle as I would like some add some feature-flag functionality in my Spring Boot application microservice (API).
I would like to "wrap" the logic in codebase with something like:
if(myCustomFeatureToggle.isActive()) {
// do some stuff if toggle is ON
}
However, I believe the Unleash API has a UI web app you can access to turn these toggles ON or OFF (1 or 0). Someone has to manually type the URL into the browser and move a slider/UI element to turn ON or OFF the "feature". However, I would like to turn "ON" these toggles based on DATE range instead. For example, I would like to set a datetime like 2021-12-30 00:00:00
, such that the toggle would become ACTIVE or ON on December 30, 2021 (without any manual intervention i.e. someone having to go to UI/web page and click some buttons). Having an "effective" and "end" date would also be awesome, i.e. end datetime for above example could be 2022-05-30 23:59:59
, such that the toggle automatically turns OFF on May 30, 2022 at 11:59 PM.
Is this possible? do any feature flags libraries have this functionality?
Upvotes: 1
Views: 1695
Reputation: 17
You could simply use Spring native @RefreshScope annotation. And when you want to change the feature flag value, just make a POST request to the actuator. You can make a simple bash/py script thats scheduled to make the request between the dates you want.
Here is a good guide: Introduction to @RefreshScope Annotation
Upvotes: 0
Reputation: 106
Yes this is possible with the help of custom activation strategies. The example do provide an example of exactly time based activation.
There also exists a issue request to support this native in Unleash. It could be good if you can add your use case as a comment on this issue.
Upvotes: 2