module control with features flags
The technique of features flags lets you activate or disable modules from a system without modifying the source code. This control can be implemented via database, configuration files, environmental variables, among other methods.
Benefits of the use of Feature Flags
- Security: allows you to launch new features at a lower risk, easily disabling them if necessary.
- gradual launch: facilitates the launch in steps, allowing you to test new features with a select user group before making them available to everyone.
- Access control: makes it possible to restrict access to certain modules based on user profiles or other rules.
- Flexibility in Maintenance: simplifies the process of maintenance and updating modules, allowing them to temporarily disable them during maintenance without affecting system operation.
- Risk Reduction: minimizes the impacts of modules with problems, allowing them to quickly disable them if errors occur.
tools and libraries for implementing feature flags
There are several tools and libraries available to assist in the implementation of
feature flags :
Launchdarkly: - https://lancharkly.com
Unleash: - https://www.getunleash.io
gofeatureflag: - https://github.com/robfig/go-feature-flag
flagsmith: - https://www.flagsmith.com
Featurehub: - https://featurehub.io
configcat: - https://configcat.com
togglz: - https://www.togglz.org
Implementation via database
To implement
feature flags using a database, follow the steps below:
Create tables to store information about the modules and their respective flags. -
Implement a middleware to intercept requisitions to modules. -
Middleware must read the database modules flags. -
activates or disable the modules according to the state of the flags. -
record and return error messages if problems occur with the modules. -
If necessary, implement user access rules for each module. -
Code Example Source: https://github.com/ortizdavid/golang-modular-software
