Repository navigation
refactor: client core - #298
vazarkevych wants to merge 15 commits into
Conversation
…entCore Both clients built their own plugins, exposure tracker, subscriptions, evaluation calls and teardown, and read typed values with ten broad catch (Exception) blocks. They are now facades over multiusermode/internal: - ClientCore: plugins, the exposure tracker, experiment subscriptions, feature and experiment evaluation, and an ordered teardown - FeatureValues: typed reads of an evaluated value, falling back to the caller's default for a missing value or another type, without broad catches Public APIs are unchanged. GrowthBook no longer resets a per-call stack on its shared context; that stack, StackContext and the constructor taking it are deprecated in favour of a new EvaluationContext constructor, and the public GrowthBook.evaluationContext field is deprecated. GrowthBookUtils.fireSubscriptions, no longer used, is deprecated. AGENTS.md records that GrowthBook uses multiusermode/internal. Behaviour changes: - shutdown() and destroy() close plugins first, so buffered events are flushed while everything else still works, and a failing step no longer skips the rest of the teardown - GrowthBookClient no longer merges the subscription state of an experiment without a key with one whose key is ""
saveAssignments replaced the stored document, so when two evaluations of the same user saved concurrently, each built from the same stale document, one assignment was lost. The saved document is now merged into the stored one, the saved assignments winning on conflict, which is atomic on a ConcurrentMap. The Redis services already merge with a compare-and-set.
Gson already provides TypeToken, so feature parsing no longer needs Guava's. Guava stays a dependency: RemoteEvalCache exposes a Guava Ticker in a public constructor.
# Conflicts: # lib/src/main/java/growthbook/sdk/java/GrowthBook.java # lib/src/main/java/growthbook/sdk/java/multiusermode/GrowthBookClient.java # lib/src/main/java/growthbook/sdk/java/multiusermode/configurations/EvaluationContext.java
Confidence Score: 5/5
[High impact] The reviewed changes appear safe to merge; both prior findings are fixed. Reviews (7) · Last reviewed commit: "fix(client): let running async evaluatio..." · Reviewed by Greptile |
Comments Outside DiffThese findings could not be posted inline.
|
# Conflicts: # lib/src/main/java/growthbook/sdk/java/multiusermode/configurations/EvaluationContext.java
|
@greptile review |
|
@greptile review |
|
@greptile review |
|
@greptile review |
|
@greptile review |
…ture values Converting through a JSON tree truncated 2.75 to 2 and overflowed 2147483648 to -2147483648 instead of returning the caller's default, as main did. Convert through JSON text again, whose reader rejects them.
…own closes them shutdown() closed plugins first, so an evaluation that finished its tracking callback during the executor's grace period notified an already-closed plugin, and the tracking plugin dropped the exposure. Sticky bucket draining, the executor grace period and pending-future resolution now run before the plugins close; the repository still outlives the plugin flush.
|
@greptile review |
Base:
refactor/repository-core· stacked on #296; review after it, this diff only shows the client stage.What
Both clients built their own plugins, exposure tracker, subscriptions, evaluation calls and teardown. They also read typed values through ten broad
catch (Exception)blocks. They are now facades overmultiusermode/internal:ClientCorehandles:GrowthBookClientpasses one sized for multi-user traffic, 10 000 entries);FeatureValuesreads an evaluated value as the caller's type. It falls back to the caller's default for a missing value or another type, without broad catches.Also:
fix(sticky):InMemoryStickyBucketServiceImpl.saveAssignmentsmerges the saved document into the stored one, atomically on aConcurrentMap. Before, two concurrent saves for the same user, both built from the same stale document, lost one assignment. The Redis services already merged with compare-and-set.TransformationUtiluses Gson'sTypeTokeninstead of Guava's.The async sticky-bucket wiring from #235 is kept and runs through
ClientCore:StickyBucketManager, the owned I/O executor,prefetchStickyBucketsandflushStickyBucketSavesstay onGrowthBookClient;ClientCore, withsuppressTrackingErrorsenabled as in fix: retry failed exposure callbacks and dedupe exposures client-wide #292;GrowthBookkeeps feat: async sticky bucket service with non-blocking reads and fire-and-forget writes #235's "no saves after a failed sticky load" guard.The CompletableFuture API from #236 runs through
ClientCoreas well:evalFeatureAsync,isOnAsync,isOffAsync,getFeatureValueAsyncandrunAsyncevaluate through the core, so async runs notify experiment subscribers and read typed values throughFeatureValues, like their sync twins;shutdown()resolves every async operation still pending once the async executor has stopped, so no caller is left waiting on a discarded task.Public API
No signature is removed. New deprecations:
EvaluationContext.StackContextand the constructor that takes it, replaced byEvaluationContext(GlobalContext, UserContext, Options);GrowthBook.evaluationContextfield;GrowthBookUtils.fireSubscriptions, which is no longer used.Behaviour changes
shutdown()/destroy()close plugins first, so buffered events are flushed while everything else still works. A failing teardown step no longer skips the rest.GrowthBookClientthen drains sticky-bucket saves and stops its executor, resolves pending async operations, then shuts down remote eval, the repository and the listener executor.main, so a constructor that throws (for example remote evaluation without a client key) never leaves started plugins behind.getFeatureValueandgetFeatureValueAsyncstill return the caller's default when evaluation fails, as documented and as onmain; only the type conversion moved toFeatureValues.GrowthBookClientno longer merges the subscription state of an experiment without a key with one whose key is"".InMemoryStickyBucketServiceImplmerges concurrent saves instead of replacing them (see above).Why
The two entry points duplicated plugin lifecycle, de-duplication and teardown, so a fix in one regularly missed the other. Running both through one core keeps them in step, as AGENTS.md requires for evaluation and refresh changes.
Verification
./gradlew build javadocon JDK 17, merged with currentmain:libgrowthbook-cache-caffeinegrowthbook-cache-jcachegrowthbook-cache-redisGuava is still a dependency of
lib.RemoteEvalCacheexposes a GuavaTickerin a public constructor, and #235'sStickyBucketManageruses a Guava cache. Removing it needs a deprecation cycle and is not part of this stack.Checklist
feat:/fix:drive the release version)AGENTS.md)--release 8on JDK 9+; the Java 8 matrix job is the backstop)CHANGELOG.md,versions.txt,Version.java,gradle.propertiesversion)libunchanged — or the change is deliberate and markedfeat!:/BREAKING CHANGE:lib(or explicitly approved); cache providers staycompileOnly