Package growthbook.sdk.java
Class GBFeaturesRepository
java.lang.Object
growthbook.sdk.java.GBFeaturesRepository
This class can be created with its `builder()` or constructor.
It will fetch the features from the endpoint provided.
Initialize with
initialize()
Get the features JSON with getFeaturesJson()
.
You would provide the features JSON when creating the GBContext
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionGBFeaturesRepository
(String apiHost, String clientKey, String encryptionKey, FeatureRefreshStrategy refreshStrategy, Integer swrTtlSeconds) Create a new GBFeaturesRepositoryGBFeaturesRepository
(String apiHost, String clientKey, String encryptionKey, FeatureRefreshStrategy refreshStrategy, Integer swrTtlSeconds, okhttp3.OkHttpClient okHttpClient) Create a new GBFeaturesRepository -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
void
void
void
initialize
(Boolean retryOnFailure) void
onFeaturesRefresh
(FeatureRefreshCallback callback) Subscribe to feature refresh events This callback is called when the features are successfully refreshed or there is an error when refreshing.void
shutdown()
-
Constructor Details
-
GBFeaturesRepository
public GBFeaturesRepository(@Nullable String apiHost, String clientKey, @Nullable String encryptionKey, @Nullable FeatureRefreshStrategy refreshStrategy, @Nullable Integer swrTtlSeconds) Create a new GBFeaturesRepository- Parameters:
apiHost
- The GrowthBook API host (default: ...)clientKey
- Your client ID, e.g. sdk-abc123encryptionKey
- optional key for decrypting encrypted payloadswrTtlSeconds
- How often the cache should be invalidated when usingFeatureRefreshStrategy.STALE_WHILE_REVALIDATE
(default: 60)
-
GBFeaturesRepository
public GBFeaturesRepository(@Nullable String apiHost, String clientKey, @Nullable String encryptionKey, @Nullable FeatureRefreshStrategy refreshStrategy, @Nullable Integer swrTtlSeconds, @Nullable okhttp3.OkHttpClient okHttpClient) Create a new GBFeaturesRepository- Parameters:
apiHost
- The GrowthBook API host (default: ...)clientKey
- Your client ID, e.g. sdk-abc123encryptionKey
- optional key for decrypting encrypted payloadswrTtlSeconds
- How often the cache should be invalidated when usingFeatureRefreshStrategy.STALE_WHILE_REVALIDATE
(default: 60)okHttpClient
- HTTP client (optional)
-
-
Method Details
-
getFeaturesJson
-
onFeaturesRefresh
Subscribe to feature refresh events This callback is called when the features are successfully refreshed or there is an error when refreshing. This is called even if the features have not changed.- Parameters:
callback
- This callback will be called when features are refreshed
-
clearCallbacks
public void clearCallbacks() -
initialize
- Throws:
FeatureFetchException
-
initialize
- Throws:
FeatureFetchException
-
shutdown
public void shutdown() -
builder
-
getFeaturesEndpoint
-
getEventsEndpoint
-
getRefreshStrategy
-
getEncryptionKey
-
getSwrTtlSeconds
-
getExpiresAt
-
getSavedGroupsJson
-