Sometimes you need a feature toggle in a rush … or just dont want to invest time in adding a feature toggle framework…

This thought came to me while I was working on some bot and had to protect myself with a feature toggle, problem was the bot was written with micro services, some in scala, some in java, some in php and even bash …

Main idea was to hold a centralised location with the feature toggle state, each service can obtain this state.

Ive made a list of the feature toggle requirement:
-Protected with some kind of Auth
-NO SSH to production machines.
-Not code changes (in app), no deployments to change state
-Change feature toggle state from any device with internet (phone, laptop, internet cafe etc…)
-Hold record of state change (to know who and when changed the feature toggle state)

End result:
-GitHub repo/gist with json file holding the feature toggle state –
-Easy to login and change the json with any device.
-GitHub availability is high.
-Each gist/repo has a change log so tracking changes is easy
-Each micro-service will make a HTTP GET request to get the feature toggle state (this is expensive IO but can be reduced with caching on a file on the system that each micro-service can read from if needed)
-Its FREE!

JSON in GitHub example:

PHP snippet, fetching the state from GitHub and deciding to act/skip the feature toggle:

Dead Simple :)

Share Button