UnlaunchClient, Cloneablepublic class OfflineUnlaunchClient extends Object implements UnlaunchClient
| Constructor | Description |
|---|---|
OfflineUnlaunchClient() |
|
OfflineUnlaunchClient(String yamlFilePath) |
| Modifier and Type | Method | Description |
|---|---|---|
AccountDetails |
accountDetails() |
Returns account details for the Unlaunch project and environment the client is connected to.
|
void |
awaitUntilReady(long timeout,
TimeUnit unit) |
Causes the current thread to wait until
UnlaunchClient is initialized, unless the thread is interrupted,
or the specified waiting time elapses. |
UnlaunchFeature |
getFeature(String flagKey,
String identity) |
Same as
UnlaunchClient.getVariation(String, String) but returns a UnlaunchFeature object that contains the
evaluated variation (variation key) and any configuration (key, value properties or JSON) associated with the
evaluated variation, defined in the Unlaunch web console. |
UnlaunchFeature |
getFeature(String flagKey,
String identity,
UnlaunchAttribute... attributes) |
Same as
UnlaunchClient.getFeature(String, String) but uses attributes that are passed as
argument when evaluating the feature flag's targeting rules. |
String |
getVariation(String flagKey,
String identity) |
Evaluates and returns the variation (variation key) for this feature.
|
String |
getVariation(String flagKey,
String identity,
UnlaunchAttribute... attributes) |
Same as
UnlaunchClient.getVariation(String, String) but uses attributes that are passed as argument when
evaluating the feature flag's targeting rules. |
boolean |
isReady() |
Returns true is the client is initialized and ready.
|
void |
shutdown() |
Closes the client by cleaning up all resources such as in memory caches, etc., stops running tasks and
rejects any new requests which arrive after this method is called.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpublic OfflineUnlaunchClient()
public OfflineUnlaunchClient(String yamlFilePath)
public AccountDetails accountDetails()
UnlaunchClientaccountDetails in interface UnlaunchClientAccountDetailspublic String getVariation(String flagKey, String identity)
UnlaunchClientThis method returns "control" if:
This method doesn't throw any exceptions nor does it return null value
getVariation in interface UnlaunchClientflagKey - the feature flag you want to evaluate.identity - unique id of your user or a unique identifier such as request or session id, email, etc. It
may be null but 'Percentage rollout' will not work because it is used to determine bucketing.
If this is null and 'Percentge rollout' is enabled, we'll log exceptions in your code and also
in the Unlaunch web app.public String getVariation(String flagKey, String identity, UnlaunchAttribute... attributes)
UnlaunchClientUnlaunchClient.getVariation(String, String) but uses attributes that are passed as argument when
evaluating the feature flag's targeting rules. Targeting rules are defined on the Unlaunch web console.
To understand attributes, suppose you have defined a feature flag with targeting rules to return certain
variation based on user's country e.g.
if country is "USA" AND subscriber is true
return "on"
otherwise
return "off"
In this example, country will be subscriber are attributes that must be passed in. If the
user is from USA and is subscriber, the "on" variation will be returned. Otherwise, "off".
client.getFeature(
"show_bonus_pack",
userId,
UnlaunchAttribute.newString("country", "USA"),
UnlaunchAttribute.newBoolean("sbscriber", true)
);
This method doesn't throw any exceptions nor does it return null value
getVariation in interface UnlaunchClientflagKey - the feature flag you want to evaluate.identity - unique id of your user or a unique identifier such as request or session id, email, etc. It
* may be null but 'Percentage rollout' will not work because it is used to determine bucketing.
* If this is null and 'Percentge rollout' is enabled, we'll log exceptions in your code and also
* in the Unlaunch web app.attributes - attributes to apply when evaluating target rules.public UnlaunchFeature getFeature(String flagKey, String identity)
UnlaunchClientUnlaunchClient.getVariation(String, String) but returns a UnlaunchFeature object that contains the
evaluated variation (variation key) and any configuration (key, value properties or JSON) associated with the
evaluated variation, defined in the Unlaunch web console.
For example, to get dynamic configuration associated with a variation, you can:
UnlaunchFeature feature = client.getFeature("new_login_ui", userId);
String colorHexCode = feature.getVariationConfig().getString("login_button_color", "#cd5c5c");
renderButton(colorHexCode);
getFeature in interface UnlaunchClientflagKey - the feature flag you want to evaluate.identity - unique id of your user or a unique identifier such as request or session id, email, etc. It
may be null but 'Percentage rollout' will not work because it is used to determine bucketing.UnlaunchFeature object that contains evaluated variation key, configuration and evaluation reason.public UnlaunchFeature getFeature(String flagKey, String identity, UnlaunchAttribute... attributes)
UnlaunchClientUnlaunchClient.getFeature(String, String) but uses attributes that are passed as
argument when evaluating the feature flag's targeting rules. Targeting rules are defined on the Unlaunch web
console.
To understand attributes, suppose you have defined a feature flag with targeting rules to return certain
variation based on user's country e.g.
if user's country is "USA" AND device is "handheld"
return "on"
otherwise
return "off"
In this example, country will be device are attributes that must be passed in.getFeature in interface UnlaunchClientflagKey - the feature flag you want to evaluate.identity - unique id of your user or a unique identifier such as request or session id, email, etc. It
may be null but 'Percentage rollout' will not work because it is used to determine bucketing.attributes - an array of attributes to evaluate againstUnlaunchFeature object that contains evaluated variation key, configuration and evaluation reason.public void awaitUntilReady(long timeout,
TimeUnit unit)
throws InterruptedException,
TimeoutException
UnlaunchClientUnlaunchClient is initialized, unless the thread is interrupted,
or the specified waiting time elapses.
If the current thread:
then InterruptedException is thrown and the current thread's interrupted status is cleared.
awaitUntilReady in interface UnlaunchClienttimeout - the maximum time to waitunit - the time unit of the timeout argumentInterruptedException - if the current thread is interrupted while waitingTimeoutException - if it times out before initialization is completepublic boolean isReady()
UnlaunchClientReturns true is the client is initialized and ready. False otherwise.
Initialized means that the client was able to download flags and data from the Unlaunch server at leasr once.
isReady in interface UnlaunchClientpublic void shutdown()
UnlaunchClientThe default behavior of this method is to block until everything has been shutdown or it encountered an error or timed out (usually a few seconds.)
shutdown in interface UnlaunchClientCopyright © 2021 Unlaunch. All rights reserved.