π A proof of concept for using Unleash feature flag service with express
- Unleash an open-source software for managing feature flags for trunk-based development.
- Documentation for Getting started with Unleash could be found here
- Docker compose file and setup can be found here
π³ Make sure that the docker service is up and running.
- Clone the
unleash-docker
repository.git clone git@github.com:murshidazher/poc-express-unleash.git
- Run
docker-compose build
in repository root folder. - Run
docker-compose up
in repository root folder.
Documentation could be found here.
An unleash proxy is need as a way for client-sdks to consume feature flags in the application.
-
Open the browser and go to localhost:4242
-
Add the default admin credentials and login
-
Go to Configure -> API access -> Configure the proxy
-
Create a token for the
unleash-proxy
and add it to thedocker-compose
. -
docker-compose up proxy
to restart the proxy. -
Verify that the proxy is running
curl -H "Content-Type: application/json" \ -H "Authorization: proxy-client-key" \ -X GET \ http://localhost:3000/proxy
- Once started up, you'll have a user with
- username:
admin
- password:
unleash4all
- username:
An example small api to fetch snake names
-
By default, the service only returns a single snake name.
-
A new product outline has come in to add a new modification to send multiple snake names instead of one.
-
Since you're doing a truck-based development you need to wrap the changes inside a feature flag.
-
We will be using the node.js SDK, but you can use whatever the SDK you prefer. The list of available SDK are here.
π‘ Open-source version only get the
default
project, we cant create more projects. π
- Select the
default
project.
π Check out the feature flags documentation for the types of feature flag that could be created.
- You can also use the unleash-client-proxy with node-fetch module to connect to the proxy instead of connecting to the server directly using API key.
- But this example uses the
unleash-client
SDK to directly connect since the communication would be amount services.
For this example, lets create a flag called fflag-get-three-snake-names
using the shell
```sh curl --location --request POST 'http://localhost:3000/api/admin/projects/default/features' \ --header 'Authorization: proxy-client-key' \ --header 'Content-Type: application/json' \ --data-raw '{ "type": "operational", "name": "fflag-get-three-snake-names", "description": "PO - Return three random snake names instead of a single snake name in response", "impressionData": true }' ```-
Enable the flag in development environment and gradual rollout to 50%
-
After feature flag response
You need to rebuild the docker-image after any changes,
docker-compose build snake-service
docker-compose up snake-service
π This section is adapted from unleash-docker docs.
Start by cloning this repository.
The unleash community has set up docker-compose
to start postgres
and the unleash server
together. This makes it really fast to start up unleash
locally without setting up a database or node.
docker-compose build
docker-compose up
On some computers, the database won't start in time for Unleash
the first time you run this.
If Unleash fails to reach the database, docker-compose restart web
usually resolves the issue.
- To give context to unleash, refer to this section of the documentation.
- For custom auth strategy, example if you need to enable a feature for QA users with some email address. Refer to this section of the documentation
- For custom redis storage, refer to this section fo the documentation and client-proxy-sdk.
My thoughts on Unleash,
- π’ Great interface and easy setup
- π‘ Would've been great if there was an extendible db setup other than PostgreSQL (ex. MongoDB)
- π΄ Pegging the number of project to 1 which is only the default project. (Open-source)
- π΄ The user access control feature for individual projects is only available for paid versions. (Open-source)
2023 Β© Unleash & Murshid Azher.