LaunchDarkly is a feature management tool for software applications. It provides feature flags to the development teams to control their software product releases and their tests.
-
Testing code live in production
Teams can create groups of users according to their specific identifiers, such as their unique keys, their regions, users’ ages etc.
Test groups can also be created according to the users’ identifiers for testing purposes.
Even if teams don’t want to classify their users, they can deploy their tests to just some percentage of the users by enabling the feature flags to x% of users.
-
Feature release management
The new deployment, new feature or any additional thing on the software product can be controlled by a feature flag.
For example, a team wanted to create a new feature for users in a specific region, let’s say in the USA.
The thing that team needs to release their new feature in this country is creating a feature flag, which is a kind of a controller for the new feature. By creating rules for this feature flag through a simple UI, teams can adjust their targets for their new feature.
The benefits of Launchdarky do not end here. You can check their website and use cases for further information.
LaunchDarkly provides a Redis® integration to make teams able to have Redis-backed feature store. At that point, Serverless Redis® comes into play as an easy, fast and feasible option.
LaunchDarkly Setup
The first step is creating a personal or team account in LaunchDarkly
After signing in, we are going to create a feature flag, that we are going to use.
To keep things simple in this demo, I am going to create a feature flag with name “test” and this flag will return a boolean value. So, the variations of this flag will be true or false.
Now, if we would like to enable some specific users, we can add those users as targets for variations of the flag.
The users may also be the other development teams in the company. If one of the teams doesn’t want to affect some teams in the same company, then they can prevent them to have the new feature by returning false to those teams.
The other option is creating rules for return values of the feature flag. It is the same logic with an “if” statement.
The example rule in the screenshot above: If the country of the user is USA, then returns true (enable the user to receive that particular feature), else false.
There are lots of options to create rules.
The one way that I most loved to adjust the distribution of the flag was percentage rollout. By this option, we can return true to the specified percentage of the users, and false to others.
LaunchDarkly Java Client Example
In this blog, we are going to work on the server side. The demo endpoint is very simple. If the feature flag is false, then return false, else true.
We are going to follow the instructions on LaunchDarkly docs.
First, we need to install the LaunchDarkly SDK as a dependency.
After that, our LaunchDarkly Java client will be like below.
The reason I created LaunchDarkly Java client like this is the warning in their docs.
In this blog, I created my API endpoint by using Spring which I feel comfortable with.
Here is the simple endpoint:
LaunchDarkly – Upstash Redis® Integration
Storing our feature flag in Redis is possible with LaunchDarkly. At that point, serverless Redis can be used as our Redis datastore for our LaunchDarkly client.
We are following the Upstash docs first, if we don’t have a Redis database yet.
Then, to connect our serverless Redis to the LaunchDarkly client, first we need to install the LaunchDarkly Java Redis library, as it is stated in their library.
After having the dependency, we can connect our serverless Redis by using LaunchDarkly Redis integration. To do that, we need to import it.
Then, we can connect it by adding configuration to the client as follows.
When we check our Upstash Redis by using the “Data Browser” tab in the console, we can see the following data.
Conclusion
LaunchDarkly is helping companies to manage their rollouts and deployments by providing feature flags.
In this blog post, we have utilized feature flags from LaunchDarkly and stored them in Upstash Redis by using the LaunchDarkly Redis integration.
Since this one was just an example demonstrates the integration, the functionality was very basic. LaunchDarkly can be used in so many ways and serverless Redis is ready to store flags.