java.lang.Object
growthbook.sdk.java.multiusermode.configurations.Options

public class Options extends Object
  • Field Details

    • DEFAULT_STICKY_BUCKET_TIMEOUT

      public static final Duration DEFAULT_STICKY_BUCKET_TIMEOUT
      Default for stickyBucketTimeout.
  • Constructor Details

  • Method Details

    • setGlobalForcedVariationsMap

      public void setGlobalForcedVariationsMap(@Nullable Map<String,?> globalForcedVariationsMap)
    • getRefreshingStrategy

      public FeatureRefreshStrategy getRefreshingStrategy()
    • getCacheMode

      public CacheMode getCacheMode()
    • getCacheDirectory

      public String getCacheDirectory()
    • getStickyBucketTimeout

      public Duration getStickyBucketTimeout()
    • isSseReconnectOnFailure

      public boolean isSseReconnectOnFailure()
    • getStickyBucketService

      @Nullable public StickyBucketService getStickyBucketService()
    • setInMemoryStickyBucketService

      public void setInMemoryStickyBucketService()
    • isStickyBucketingConfigured

      public boolean isStickyBucketingConfigured()
      Whether either flavor of sticky bucket service is configured.
      Returns:
      true when a sync or async sticky bucket service is set
    • setGlobalAttributes

      public void setGlobalAttributes(@Nullable String attributesJson)
    • isRemoteEvalEnabled

      public boolean isRemoteEvalEnabled()
    • builder

      public static Options.OptionsBuilder builder()
    • getEnabled

      @Nullable public Boolean getEnabled()
      Whether globally all experiments are enabled (default: true) Switch to globally disable all experiments.
    • getIsQaMode

      public Boolean getIsQaMode()
      If true, random assignment is disabled and only explicitly forced variations are used.
    • getIsCacheDisabled

      public Boolean getIsCacheDisabled()
    • getAllowUrlOverrides

      public Boolean getAllowUrlOverrides()
      Boolean flag to allow URL overrides (default: false)
    • getUrl

      @Nullable public String getUrl()
    • getApiHost

      @Nullable public String getApiHost()
    • getClientKey

      @Nullable public String getClientKey()
    • getDecryptionKey

      @Nullable public String getDecryptionKey()
      Optional decryption Key. If this is not null, featuresJson should be an encrypted payload.
    • getStickyBucketIdentifierAttributes

      @Nullable public List<String> getStickyBucketIdentifierAttributes()
      Attribute keys whose sticky bucket documents are read for every user, in addition to the attributes the loaded features' experiments hash on (those are always read). Needed only for attributes the SDK cannot derive, such as the hash attribute of an inline experiment.
    • getTrackingCallBackWithUser

      @Nullable public TrackingCallbackWithUser getTrackingCallBackWithUser()
      A function that takes Experiment and ExperimentResult as arguments.
    • getFeatureUsageCallbackWithUser

      @Nullable public FeatureUsageCallbackWithUser getFeatureUsageCallbackWithUser()
      A function that takes String and FeatureResult as arguments. A callback that will be invoked every time a feature is viewed. Listen for feature usage events
    • getRefreshStrategy

      @Nullable public FeatureRefreshStrategy getRefreshStrategy()
      Strategy for building url
    • getSwrTtlSeconds

      @Nullable public Integer getSwrTtlSeconds()
      The standard cache TTL to use.
    • getGlobalAttributes

      @Nullable public com.google.gson.JsonObject getGlobalAttributes()
      Map of user attributes that are used to assign variations
    • getAttributesJson

      @Nullable public String getAttributesJson()
      String format of user attributes that are used to assign variations
    • getGlobalForcedFeatureValues

      @Nullable public Map<String,Object> getGlobalForcedFeatureValues()
      Manual force feature values
    • getGlobalForcedVariationsMap

      @Nullable public Map<String,Integer> getGlobalForcedVariationsMap()
      Force specific experiments to always assign a specific variation (used for QA)
    • getFeatureRefreshCallback

      @Deprecated @Nullable public FeatureRefreshCallback getFeatureRefreshCallback()
      Deprecated.
      Use GrowthBookClient.addFeatureRefreshListener(...) or GrowthBookClient.subscribeFeatureRefreshListener(...) after constructing the client.
      Legacy feature refresh callback.
    • getCacheManager

      @Nullable public GbCacheManager getCacheManager()
    • getFeatureRefreshListenerExecutor

      @Nullable public Executor getFeatureRefreshListenerExecutor()
      Optional executor for client-level feature refresh listeners. When not supplied, the client dispatches listener callbacks on a dedicated daemon thread it owns and shuts down.
    • getPlugins

      @Nullable public List<GrowthBookPlugin> getPlugins()
      Plugins registered with the GrowthBook client. See GrowthBookPlugin and GrowthBookTrackingPlugin. The owning client builds a per-instance PluginRegistry from this list; the registry itself is carried on EvaluationContext, not here, so reusing one Options across clients stays isolated.
    • getBackgroundFetchInterval

      @Nullable public Duration getBackgroundFetchInterval()
      Optional minimum interval between non-forced background feature refreshes.
    • getRetryPolicy

      @Nullable public FeatureFetchRetryPolicy getRetryPolicy()
      Optional bounded retry policy. Repositories use the default policy when null.
    • getRemoteEval

      public Boolean getRemoteEval()
    • getCacheKeyAttributes

      @Nullable public List<String> getCacheKeyAttributes()
    • getRemoteEvalCacheSize

      public Integer getRemoteEvalCacheSize()
    • getRemoteEvalCacheTtlSeconds

      @Nullable public Integer getRemoteEvalCacheTtlSeconds()
      Hard expiry (seconds) for cached remote-eval responses; null disables time-based expiry.
    • getSseReconnectOnFailure

      @Nullable public Boolean getSseReconnectOnFailure()
      Whether the multi-user client reconnects the SSE stream after an abnormal failure or a server close. Reconnect attempts are bounded by retryPolicy. Defaults to true.
    • getAsyncStickyBucketService

      @Nullable public AsyncStickyBucketService getAsyncStickyBucketService()
      Non-blocking sticky bucket service for the multi-user client. Mutually exclusive with stickyBucketService — configure exactly one. See AsyncStickyBucketService for the contract.

      A failed read from either kind of service is logged and that evaluation continues with normal bucketing, but none of its assignments are saved: a variation bucketed without the stored assignment must not replace it.

    • getAsyncExecutor

      @Nullable public Executor getAsyncExecutor()
      Executor for the client's asynchronous entry points: offloading blocking StickyBucketService calls and composing async evaluations. The synchronous evaluation API never uses it; it calls a blocking service on the calling thread. When null, the client creates its own bounded daemon pool and shuts it down in shutdown(); a caller-supplied executor is never shut down by the SDK. On JDK 21+, pass Executors.newVirtualThreadPerTaskExecutor() so blocking offloads scale with the store instead of a fixed pool.
    • getStickyBucketCacheTtlSeconds

      @Nullable public Long getStickyBucketCacheTtlSeconds()
      Opt-in TTL, in seconds, for caching sticky bucket reads per user attributes. Null or non-positive (the default) disables caching: assignments are fetched per evaluation, so assignment changes made by other processes are picked up promptly. Enabling trades that freshness for fewer store lookups on hot users.
    • getStickyBucketCacheSize

      public Integer getStickyBucketCacheSize()
      Maximum entries in the opt-in sticky bucket read cache (default 1000). Non-positive disables caching. Only meaningful when stickyBucketCacheTtlSeconds is set.
    • setEnabled

      public void setEnabled(@Nullable Boolean enabled)
      Whether globally all experiments are enabled (default: true) Switch to globally disable all experiments.
    • setIsQaMode

      public void setIsQaMode(Boolean isQaMode)
      If true, random assignment is disabled and only explicitly forced variations are used.
    • setIsCacheDisabled

      public void setIsCacheDisabled(Boolean isCacheDisabled)
    • setAllowUrlOverrides

      public void setAllowUrlOverrides(Boolean allowUrlOverrides)
      Boolean flag to allow URL overrides (default: false)
    • setUrl

      public void setUrl(@Nullable String url)
    • setApiHost

      public void setApiHost(@Nullable String apiHost)
    • setClientKey

      public void setClientKey(@Nullable String clientKey)
    • setDecryptionKey

      public void setDecryptionKey(@Nullable String decryptionKey)
      Optional decryption Key. If this is not null, featuresJson should be an encrypted payload.
    • setStickyBucketIdentifierAttributes

      public void setStickyBucketIdentifierAttributes(@Nullable List<String> stickyBucketIdentifierAttributes)
      Attribute keys whose sticky bucket documents are read for every user, in addition to the attributes the loaded features' experiments hash on (those are always read). Needed only for attributes the SDK cannot derive, such as the hash attribute of an inline experiment.
    • setStickyBucketService

      public void setStickyBucketService(@Nullable StickyBucketService stickyBucketService)
      Service that provide functionality of Sticky Bucketing
    • setTrackingCallBackWithUser

      public void setTrackingCallBackWithUser(@Nullable TrackingCallbackWithUser trackingCallBackWithUser)
      A function that takes Experiment and ExperimentResult as arguments.
    • setFeatureUsageCallbackWithUser

      public void setFeatureUsageCallbackWithUser(@Nullable FeatureUsageCallbackWithUser featureUsageCallbackWithUser)
      A function that takes String and FeatureResult as arguments. A callback that will be invoked every time a feature is viewed. Listen for feature usage events
    • setRefreshStrategy

      public void setRefreshStrategy(@Nullable FeatureRefreshStrategy refreshStrategy)
      Strategy for building url
    • setSwrTtlSeconds

      public void setSwrTtlSeconds(@Nullable Integer swrTtlSeconds)
      The standard cache TTL to use.
    • setAttributesJson

      public void setAttributesJson(@Nullable String attributesJson)
      String format of user attributes that are used to assign variations
    • setGlobalForcedFeatureValues

      public void setGlobalForcedFeatureValues(@Nullable Map<String,Object> globalForcedFeatureValues)
      Manual force feature values
    • setFeatureRefreshCallback

      @Deprecated public void setFeatureRefreshCallback(@Nullable FeatureRefreshCallback featureRefreshCallback)
      Deprecated.
      Use GrowthBookClient.addFeatureRefreshListener(...) or GrowthBookClient.subscribeFeatureRefreshListener(...) after constructing the client.
      Legacy feature refresh callback.
    • setCacheManager

      public void setCacheManager(@Nullable GbCacheManager cacheManager)
    • setCacheMode

      public void setCacheMode(CacheMode cacheMode)
    • setCacheDirectory

      public void setCacheDirectory(@Nullable String cacheDirectory)
    • setFeatureRefreshListenerExecutor

      public void setFeatureRefreshListenerExecutor(@Nullable Executor featureRefreshListenerExecutor)
      Optional executor for client-level feature refresh listeners. When not supplied, the client dispatches listener callbacks on a dedicated daemon thread it owns and shuts down.
    • setPlugins

      public void setPlugins(@Nullable List<GrowthBookPlugin> plugins)
      Plugins registered with the GrowthBook client. See GrowthBookPlugin and GrowthBookTrackingPlugin. The owning client builds a per-instance PluginRegistry from this list; the registry itself is carried on EvaluationContext, not here, so reusing one Options across clients stays isolated.
    • setBackgroundFetchInterval

      public void setBackgroundFetchInterval(@Nullable Duration backgroundFetchInterval)
      Optional minimum interval between non-forced background feature refreshes.
    • setRetryPolicy

      public void setRetryPolicy(@Nullable FeatureFetchRetryPolicy retryPolicy)
      Optional bounded retry policy. Repositories use the default policy when null.
    • setRemoteEval

      public void setRemoteEval(Boolean remoteEval)
    • setCacheKeyAttributes

      public void setCacheKeyAttributes(@Nullable List<String> cacheKeyAttributes)
    • setRemoteEvalCacheSize

      public void setRemoteEvalCacheSize(Integer remoteEvalCacheSize)
    • setRemoteEvalCacheTtlSeconds

      public void setRemoteEvalCacheTtlSeconds(@Nullable Integer remoteEvalCacheTtlSeconds)
      Hard expiry (seconds) for cached remote-eval responses; null disables time-based expiry.
    • setSseReconnectOnFailure

      public void setSseReconnectOnFailure(@Nullable Boolean sseReconnectOnFailure)
      Whether the multi-user client reconnects the SSE stream after an abnormal failure or a server close. Reconnect attempts are bounded by retryPolicy. Defaults to true.
    • setAsyncStickyBucketService

      public void setAsyncStickyBucketService(@Nullable AsyncStickyBucketService asyncStickyBucketService)
      Non-blocking sticky bucket service for the multi-user client. Mutually exclusive with stickyBucketService — configure exactly one. See AsyncStickyBucketService for the contract.

      A failed read from either kind of service is logged and that evaluation continues with normal bucketing, but none of its assignments are saved: a variation bucketed without the stored assignment must not replace it.

    • setAsyncExecutor

      public void setAsyncExecutor(@Nullable Executor asyncExecutor)
      Executor for the client's asynchronous entry points: offloading blocking StickyBucketService calls and composing async evaluations. The synchronous evaluation API never uses it; it calls a blocking service on the calling thread. When null, the client creates its own bounded daemon pool and shuts it down in shutdown(); a caller-supplied executor is never shut down by the SDK. On JDK 21+, pass Executors.newVirtualThreadPerTaskExecutor() so blocking offloads scale with the store instead of a fixed pool.
    • setStickyBucketCacheTtlSeconds

      public void setStickyBucketCacheTtlSeconds(@Nullable Long stickyBucketCacheTtlSeconds)
      Opt-in TTL, in seconds, for caching sticky bucket reads per user attributes. Null or non-positive (the default) disables caching: assignments are fetched per evaluation, so assignment changes made by other processes are picked up promptly. Enabling trades that freshness for fewer store lookups on hot users.
    • setStickyBucketCacheSize

      public void setStickyBucketCacheSize(Integer stickyBucketCacheSize)
      Maximum entries in the opt-in sticky bucket read cache (default 1000). Non-positive disables caching. Only meaningful when stickyBucketCacheTtlSeconds is set.
    • setStickyBucketTimeout

      public void setStickyBucketTimeout(@Nullable Duration stickyBucketTimeout)
      How long the multi-user client waits for one sticky bucket store call, read or save (default DEFAULT_STICKY_BUCKET_TIMEOUT, 5 seconds). A read that takes longer is handled like any failed read: that evaluation continues with normal bucketing and saves nothing. A save that takes longer is handled like any failed save. Duration.ZERO disables the timeout.

      The store call itself is not cancelled. A blocking StickyBucketService called by the synchronous evaluation API runs on the calling thread and is bounded by its own client's timeout, not by this one.

    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object