public class JCurtain
extends java.lang.Object
| Constructor and Description |
|---|
JCurtain(redis.clients.jedis.JedisPool jedisPool)
Creates an instance of JCurtain
|
JCurtain(java.net.URI uri)
Creates an instance of JCurtain
|
| Modifier and Type | Method and Description |
|---|---|
Feature |
getFeature(java.lang.String name)
This method returns a
Feature object with the feature configuration and members. |
boolean |
isOpen(java.lang.String feature)
Checks if your feature is open.
|
boolean |
isOpen(java.lang.String feature,
java.lang.String user)
Checks if the specified feature is open for the user.
|
void |
openFeatureForUser(java.lang.String feature,
java.lang.String user)
This method opens a feature for an user
|
public JCurtain(redis.clients.jedis.JedisPool jedisPool)
jedisPool - your pre-configured JedisPool variablepublic JCurtain(java.net.URI uri)
uri - your redis URI, e.g.: redis://:p4ssw0rd@10.0.1.1:6380/15public boolean isOpen(java.lang.String feature)
Checks if your feature is open.
You must have a Redis key with name "feature:[name-of-feature]:percentage" with value between 0 and 100.
Examples:
If you're in the last case then JCurtain will generate a random number X between 0 and 100 and will calculate if your defined percentage P is greater than X. If that condition is true then the feature is open for this method call. Subsequent method calls can generate different results.
feature - the feature nametrue if openpublic boolean isOpen(java.lang.String feature,
java.lang.String user)
Checks if the specified feature is open for the user.
This method first checks if the user is member of the Set stored at the
Redis key "feature:[name-of-feature]:members".
If the user is not present in the list and your feature is configured with percentage
then this method will behave like isOpen(feature)
Note that you can open your feature to a restrict set of users by using 0 of percentage.
feature - the feature nameuser - the unique identifier for the user (email, login, sequential ID etc)true if openpublic void openFeatureForUser(java.lang.String feature,
java.lang.String user)
feature - the feature nameuser - the unique identifier for the user (email, login, sequential ID etc)