Java SDK for featureflow
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.mvn/wrapper
src
.gitignore
CODE_OF_CONDUCT.md
LICENSE
README.md
circle.yml
codesigning.asc.enc
deploy-prod.sh
mvn-deploy-snapshot-to-central.sh
mvn-versions-set.sh
mvnw
mvnw.cmd
pom.xml
settings.xml

README.md

featureflow-java-sdk

Featureflow Java Client SDK

Get your Featureflow account at featureflow.io

Get Started

The easiest way to get started is to follow the Featureflow quick start guides

Change Log

Please see CHANGELOG.

Installation

Using Maven

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

Usage

Quick start

Get your 'Server Environment Api Key' from the environment page in featureflow and instantiate a singleton client:

String apiKey = "<Your Server Environment Api Key goes here>";
FeatureflowClient featureflow = FeatureflowClient.builder(apiKey).build();

This is a singleton, so if you're using spring you should make it a @Bean in a @Configuration class.

In your code, you can test the value of your feature where the value of my-feature-key is equal to 'on'

  if (featureflow.evaluate('my-feature-key', user).is('on')){
    // this feature code will be run because 'my-feature-key' is set to 'on'
  }

Because the default variants for any feature are 'on' and 'off', we have provided two helper methods .isOn() and .isOff()

if(featureflow.evaluate('my-feature-key', user).isOn()){
  // this feature code will be run because 'my-feature-key' is set to 'on'
}

if(featureflow.evaluate('my-feature-key', user).isOff()){
  // this feature code won't be run because 'my-feature-key' is not set to 'off'
}

Adding a User

You can pass user information in to allow features to be targeted. At the point in time of evaluation (e.g. on a rest call or other call) you can create and pass in a user by creating a FeatureflowUser object. We have a builder to help:

FeatureflowUser user = new FeatureflowUser("uniqueuserId")
    .withAttribute("tier", "silver")
    .withAttribute("age", 32)
    .withAttribute("signup_date", new DateTime(2017, 1, 1, 12, 0, 0, 0))    
    .withAttribute("name", "Joe User")
    .withAttribute("email", "user@featureflow.io")
    .withAttributes("user_role", Arrays.asList("pvt_tester", "administrator"))
    .build();

User attributes can be of type DateTime, Number, String or List<DateTime>, List<Number>, List<String>

When a list of user attributes is passed in, each rule may match any of the attribute values, additionally each attribute is stored in featureflow for subsequent lookup in rule creation.

If you do not want the user saved in featureflow set '.saveUser(false)' on the FeatureflowUser object.

Evaluate by passing the user into the evaluate method:

featureflow.evaluate("example-feature", user).value());

Further documentation can be found here

About featureflow

Roadmap

  • Multiple callbacks
  • Offline mode
  • Read only mode

License

Apache-2.0