Class RemoteEvalCoordinator
java.lang.Object
growthbook.sdk.java.multiusermode.internal.RemoteEvalCoordinator
INTERNAL: not part of the supported API. Public only because
GrowthBookClient lives in
the parent package — treat its signatures as free to change without a major version bump.
Keeps remote-evaluation fetching, caching, SSE-based cache invalidation, and per-user
evaluation context creation outside of the public facade.
This is the remote-eval counterpart to GlobalContextManager/
FeatureRepositoryProvider: the GrowthBookClient facade delegates to it instead
of carrying remote-eval-specific state and control flow itself.
-
Constructor Summary
ConstructorsConstructorDescriptionRemoteEvalCoordinator(Options options, FeatureRefreshListenerRegistry refreshListeners) Creates a coordinator bound to the client options instance. -
Method Summary
Modifier and TypeMethodDescriptioncreateEvaluationContext(UserContext userContext) Creates an evaluation context for a user by fetching (or reusing a cached) remote response.intbooleanPrepares the remote-eval service, cache, and (when configured) the SSE invalidation channel.voidDrops all cached remote responses; the next evaluation refetches per user context.booleanbooleanisReady()booleanpreload(UserContext userContext) Warms the cache for a user context without producing an evaluation context.voidrefresh(RequestBodyForRemoteEval requestBodyForRemoteEval) Fetches a fresh response for an explicit payload, refreshes the fallback context, and clears the cache so the next evaluation uses the latest data.voidshutdown()Releases the service, cache, and SSE invalidation resources owned by this coordinator.
-
Constructor Details
-
RemoteEvalCoordinator
Creates a coordinator bound to the client options instance.- Parameters:
options- client options used to drive remote evaluationrefreshListeners- registry used to publish SSE-driven refresh events to subscribers
-
-
Method Details
-
initialize
public boolean initialize()Prepares the remote-eval service, cache, and (when configured) the SSE invalidation channel.- Returns:
trueonce the coordinator is ready to evaluate
-
createEvaluationContext
Creates an evaluation context for a user by fetching (or reusing a cached) remote response. Falls back to an empty local context when the remote request fails or after shutdown.- Parameters:
userContext- per-user evaluation context- Returns:
- evaluation context used by feature and experiment evaluators
-
preload
Warms the cache for a user context without producing an evaluation context.- Parameters:
userContext- per-user evaluation context- Returns:
truewhen the response was fetched (or already cached)
-
refresh
Fetches a fresh response for an explicit payload, refreshes the fallback context, and clears the cache so the next evaluation uses the latest data.- Parameters:
requestBodyForRemoteEval- remote evaluation request payload- Throws:
FeatureFetchException- when the remote request fails
-
isReady
public boolean isReady()- Returns:
trueonce remote evaluation has been initialized and is ready to serve.
-
isCacheConfigured
public boolean isCacheConfigured()- Returns:
truewhen a remote-eval response cache has been created.
-
fallbackFeatureCount
public int fallbackFeatureCount()- Returns:
- number of features in the remote-eval fallback context (0 when none).
-
invalidateCache
public void invalidateCache()Drops all cached remote responses; the next evaluation refetches per user context. -
shutdown
public void shutdown()Releases the service, cache, and SSE invalidation resources owned by this coordinator.Synchronized on the same monitor as
getService(),getCache(), andensureReady()so teardown cannot interleave with lazy creation. In-flight callers already holding a reference are unaffected:RemoteEvalCache.getreports a closed cache as aFeatureFetchException, which callers handle as a fallback.
-