Skip to main content

Quick start - server

This Quick start is designed to get featureflow into your existing application as quickly as possible.

Install the Featureflow client

<dependency>
<groupId>io.featureflow</groupId>
<artifactId>featureflow-java-sdk</artifactId>
<version>1.1.2</version>
</dependency>

Create a Featureflow client and register features

info

The featureflow client must be a Singleton in your application.

Do not instantiate featureflow on every request This will cause a reload of features every time which will incur a performance penalty and excessive usage.

The Featureflow Client will maintain an optimised cache of all your feature rules.

FeatureflowClient client = new  FeatureflowClient
.Builder({Server Environment Api Key})
.withFeatures(Arrays.asList(
new Feature("logout-button", Variant.off),
new Feature("example-feature", Variant.off)),
));

//The client is a singleton, so for example if you use spring you might declare it in a @Configuration class.

//we recommend that you use an enum for your feature keys - this helps you track them in your IDE and reduces debt.

Your 'Server Environment SDK Key' is available on your environment page in featureflow.

You may wish to register your features at startup. This provides additional benefits - we know immediately when a feature is available in an environment, you can provide an alternative failover variant (the default is 'off') - the failover variant is the variant that is chosen if there is no matching feature available to evaluate (if you are offline with no cache, misconfigured or the feature has not been created yet in featureflow). It also helps as a central place to refer to all your currently deployed features.

Evaluate a feature

//Without User
if(featureflowClient.evaluate("example-feature").isOn())) {
//do something
} else {
//do not do something
}

//With a User
FeatureflowUser user = new FeatureflowUser("uniqueUserId")
.withAttribute("tier", "silver")
.withAttribute("age", 32)
.withAttribute("signup_date", new DateTime(2017, 1, 1, 12, 0, 0, 0));

if(featureflowClient.evaluate("example-feature", user).isOn()) {
//do something
}

In the Server-side SDK's we create a FeatureFlow User and pass that into the 'evaluate' method. The FeatureflowUser contains a a set of name/value pairs which give featureflow information on which you can base your feature rules. If you do not provide a user we will assume the user is 'anonymous'.

Try it out!

You may now fire up your application - keep an eye on the features list in the featureflow admin panel and you will see your features appear with default on/off settings.

Congratulations you're done!

If you wish of course you can create the features via the featureflow UI - featureflow will make the connection using the feature Key. To do this click 'New Feature' (in any environment) and enter a name and key:

Create Feature

You will see your feature in the list - you will notice that it has an empty green circle next to it - this means we have not seen the feature yet in the environment.

  • Register or evaluate the new feature in your SDK code (you can find the feature Key in the feature detail modal)
  • Restart your application - You will find that the icon has updated to a ticked green circle as soon as we detect your new feature (ensure you're looking at the environment that matches your SDK environment key).

Status Icon

Thats the basics to get started.

Check out the User guide for to learn how to manage gradual rollouts, targeting, and multiple feature variants.

You may wish to try the javascript client SDK started to manage your front-end.