Feature Flag
Problem Statement
Implement a feature flag library that exposes a single function. The function takes the flag's name and an optional map of values
flag.is_on("give_discount", {"user": "user_name", "product": "product_id"})
Design everything that is necessary for engineers to create and modify flags.
You're building a feature flag library that ships with your codebase.
Such a library would allow engineers to toggle functionality using flags without deploying new code. The library exposes a single static API to check whether a feature flag is enabled for a given context.
Example usage:
1# Should we enable a new integration?
2if flag.is_on("enable-new-integration"):
3 # Execute integration logic
4 ...
5
6# Should we calculate tax for this user?
7if flag.is_on("enable-tax-calculation"):
8 # Execute tax calculation
9 ...To enable engineers to quickly turn feature flags on or off, the system should provide a web interface where flags can be toggled dynamically.
It is the responsibility of your system to interpret the flag parameters appropriately based on how they’ve been modified through the UI.
Task:
Starting from just the interface described above, design a complete system for:
You should address: