Package co.featbit.server.exterior
Interface FBClient
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
FBClientImp
This interface defines the public methods of
FBClientImp.
Applications will normally interact directly with FBClientImp
and must use its constructor to initialize the SDK.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanboolVariation(String featureFlagKey, FBUser user, Boolean defaultValue) Calculates the boolean value of a feature flag for a given user.boolVariationDetail(String featureFlagKey, FBUser user, Boolean defaultValue) Calculates the value of a feature flag for a given user, and returns an object that describes the way the value was determined.doubledoubleVariation(String featureFlagKey, FBUser user, Double defaultValue) Calculates the double value of a feature flag for a given user.doubleVariationDetail(String featureFlagKey, FBUser user, Double defaultValue) Calculates the double value of a feature flag for a given user, and returns an object that describes the way the value was determined.voidflush()Flushes all pending events.Returns a list of all feature flags value with details for a given user, including the reason that describes the way the value was determined, that can be used on the client side sdk or a front end .Returns an interface for tracking the status of the update processor.voidregister a userbooleaninitialization in the offline modeintintVariation(String featureFlagKey, FBUser user, Integer defaultValue) Calculates the integer value of a feature flag for a given user.intVariationDetail(String featureFlagKey, FBUser user, Integer defaultValue) Calculates the int value of a feature flag for a given user, and returns an object that describes the way the value was determined.booleanalias of boolVariation for a given userbooleanisFlagKnown(String featureKey) Returns true if the specified feature flag currently exists.booleanTests whether the client is ready to be used.<T> TjsonVariation(String featureFlagKey, FBUser user, Class<T> clazz, T defaultValue) Calculates the json value of a feature flag for a given user.<T> FlagState<T>jsonVariationDetail(String featureFlagKey, FBUser user, Class<T> clazz, T defaultValue) Calculates the json value of a feature flag for a given user, and returns an object that describes the way the value was determined.longlongVariation(String featureFlagKey, FBUser user, Long defaultValue) Calculates the long value of a feature flag for a given user.longVariationDetail(String featureFlagKey, FBUser user, Long defaultValue) Calculates the long value of a feature flag for a given user, and returns an object that describes the way the value was determined.voidtrackMetric(FBUser user, String eventName) tracks that a user performed an event and provides a default numeric value for custom metricsvoidtrackMetric(FBUser user, String eventName, double metricValue) tracks that a user performed an event, and provides an additional numeric value for custom metrics.voidtrackMetrics(FBUser user, String... eventNames) tracks that a user performed a series of events with default numeric value for custom metricsvoidtrackMetrics(FBUser user, Map<String, Double> metrics) tracks that a user performed a series of eventsCalculates the value of a feature flag for a given user.variationDetail(String featureFlagKey, FBUser user, String defaultValue) Calculates the value of a feature flag for a given user, and returns an object that describes the way the value was determined.
-
Method Details
-
isInitialized
boolean isInitialized()Tests whether the client is ready to be used.- Returns:
- true if the client is ready, or false if it is still initializing
-
variation
Calculates the value of a feature flag for a given user.- Parameters:
featureFlagKey- the unique key for the feature flaguser- the end user requesting the flagdefaultValue- the default value of the flag- Returns:
- the variation for the given user, or
defaultValueif the flag is disabled or an error occurs
-
boolVariation
Calculates the boolean value of a feature flag for a given user.- Parameters:
featureFlagKey- the unique key for the feature flaguser- the end user requesting the flagdefaultValue- the default value of the flag- Returns:
- if the flag should be enabled, or
defaultValueif the flag is disabled or an error occurs
-
isEnabled
alias of boolVariation for a given user- Parameters:
featureFlagKey- the unique key for the feature flaguser- the end user requesting the flag- Returns:
- if the flag should be enabled, or false if the flag is disabled, or an error occurs
-
doubleVariation
Calculates the double value of a feature flag for a given user.- Parameters:
featureFlagKey- the unique key for the feature flaguser- the end user requesting the flagdefaultValue- the default value of the flag- Returns:
- the variation for the given user, or
defaultValueif the flag is disabled or an error occurs
-
intVariation
Calculates the integer value of a feature flag for a given user. Note that If the variation has a numeric value, but not an integer, it is rounded toward zero(DOWN mode)- Parameters:
featureFlagKey- the unique key for the feature flaguser- the end user requesting the flagdefaultValue- the default value of the flag- Returns:
- the variation for the given user, or
defaultValueif the flag is disabled or an error occurs
-
longVariation
Calculates the long value of a feature flag for a given user. Note that If the variation has a numeric value, but not a long value, it is rounded toward zero(DOWN mode)- Parameters:
featureFlagKey- the unique key for the feature flaguser- the end user requesting the flagdefaultValue- the default value of the flag- Returns:
- the variation for the given user, or
defaultValueif the flag is disabled or an error occurs
-
jsonVariation
Calculates the json value of a feature flag for a given user.- Type Parameters:
T- json object type- Parameters:
featureFlagKey- the unique key for the feature flaguser- the end user requesting the flagclazz- json deserialization classdefaultValue- the default value of the flag- Returns:
- the variation for the given user, or
defaultValueif the flag is disabled, current user doesn't exist
-
isFlagKnown
Returns true if the specified feature flag currently exists.- Parameters:
featureKey- the unique key for the feature flag- Returns:
- true if the flag exists
-
getDataUpdateStatusProvider
Status.DataUpdateStatusProvider getDataUpdateStatusProvider()Returns an interface for tracking the status of the update processor.The update processor is the mechanism that the SDK uses to get feature flag, such as a streaming connection. The
Status.DataUpdateStatusProvideris used to check whether the update processor is currently operational- Returns:
- a
Status.DataUpdateStatusProvider
-
initializeFromExternalJson
initialization in the offline mode- Parameters:
json- feature flags in the json format- Returns:
- true if the initialization is well done
- Throws:
JsonParseException- if json is invalid
-
getAllLatestFlagsVariations
Returns a list of all feature flags value with details for a given user, including the reason that describes the way the value was determined, that can be used on the client side sdk or a front end .note that this method does not send insight events back to feature flag center.
- Parameters:
user- the end user requesting the flag- Returns:
- a
AllFlagStates
-
variationDetail
Calculates the value of a feature flag for a given user, and returns an object that describes the way the value was determined.- Parameters:
featureFlagKey- the unique key for the feature flaguser- the end user requesting the flagdefaultValue- the default value of the flag- Returns:
- an
FlagStateobject
-
boolVariationDetail
Calculates the value of a feature flag for a given user, and returns an object that describes the way the value was determined.- Parameters:
featureFlagKey- the unique key for the feature flaguser- the end user requesting the flagdefaultValue- the default value of the flag- Returns:
- an
FlagStateobject
-
doubleVariationDetail
Calculates the double value of a feature flag for a given user, and returns an object that describes the way the value was determined.- Parameters:
featureFlagKey- the unique key for the feature flaguser- the end user requesting the flagdefaultValue- the default value of the flag- Returns:
- an
FlagStateobject
-
intVariationDetail
Calculates the int value of a feature flag for a given user, and returns an object that describes the way the value was determined.Note that If the variation has a numeric value, but not an int value, it is rounded toward zero(DOWN mode)
- Parameters:
featureFlagKey- the unique key for the feature flaguser- the end user requesting the flagdefaultValue- the default value of the flag- Returns:
- an
FlagStateobject
-
longVariationDetail
Calculates the long value of a feature flag for a given user, and returns an object that describes the way the value was determined.Note that If the variation has a numeric value, but not a long value, it is rounded toward zero(DOWN mode)
- Parameters:
featureFlagKey- the unique key for the feature flaguser- the end user requesting the flagdefaultValue- the default value of the flag- Returns:
- an
FlagStateobject
-
jsonVariationDetail
<T> FlagState<T> jsonVariationDetail(String featureFlagKey, FBUser user, Class<T> clazz, T defaultValue) Calculates the json value of a feature flag for a given user, and returns an object that describes the way the value was determined.- Type Parameters:
T- json object type- Parameters:
featureFlagKey- the unique key for the feature flaguser- the end user requesting the flagclazz- json deserialization classdefaultValue- the default value of the flag- Returns:
- an
FlagStateobject
-
flush
void flush()Flushes all pending events. -
identify
register a user- Parameters:
user- user to register
-
trackMetric
tracks that a user performed an event and provides a default numeric value for custom metrics- Parameters:
user- the user that performed the eventeventName- the name of the event
-
trackMetric
tracks that a user performed an event, and provides an additional numeric value for custom metrics.- Parameters:
user- the user that performed the eventeventName- the name of the eventmetricValue- a numeric value used by the experimentation feature in numeric custom metrics.
-
trackMetrics
tracks that a user performed a series of events with default numeric value for custom metrics- Parameters:
user- the user that performed the eventeventNames- event names
-
trackMetrics
tracks that a user performed a series of events- Parameters:
user- the user that performed the eventmetrics- event name and numeric value in K/V
-