In my company, our CTO mentions Trunk-Based Development that we want to implement. It sounds great for fast development, instead of using git-flow, everyone can directly push to master. Not everyone happy with that, most common question is: How to make sure our user sees only features that ready.
That's why feature flag come to play. Usually, if we want to release our new feature, we will deploy our latest feature and it will be available. With feature flag, we can deploy everything and enable it later. We just create if this_feature_enable == True
in every initial point that called the feature and make this_feature_enable
changeable on-the-fly. We use flagr for that.
To use it, we can easily run flagr docker docker run -it -p 18000:18000 checkr/flagr
, it come with beautiful UI for starting up. It also have SDK for some language: Python, Go, JS and Ruby. If your favorite language is not on the list, we can access all the data with Restful API.
I have a condition that client app have features differently based on who is the client. Instead of creating so many diffent app for every client, I will utilize this feature flag to an action. So here is my scenario:
- Client side app login to server app
- Server app verify client and ask flagr which features they are eligible
- Flagr send list of features, server app simplify the response structure
- Client app receive JWT + Feature List, reconstruct the app based on list
- Client app will use the configuration in offline mode, and verify the list in local with server if in sync mode.
I implement all the step in my repo. Client side will using Nuxt App with PWA enable. Server side will using Django. You can easily try it using docker-compose up
. Cheers.