Class SyncOffloadStickyBucketAdapter
java.lang.Object
growthbook.sdk.java.stickyBucketing.SyncOffloadStickyBucketAdapter
- All Implemented Interfaces:
AsyncStickyBucketService
public final class SyncOffloadStickyBucketAdapter
extends Object
implements AsyncStickyBucketService
Presents a blocking
StickyBucketService as an
AsyncStickyBucketService by running each call on the supplied
executor. The multi-user client uses it for its asynchronous entry points,
which must not block their caller; its synchronous evaluation API calls the
blocking service on the calling thread instead. It is public so applications
composing their own pipelines can reuse it.
getAllAssignments(java.util.Map<java.lang.String, java.lang.String>) is offloaded as ONE task wrapping the
delegate's own getAllAssignments, preserving batched implementations
(e.g. a single Redis MGET) instead of exploding them into N calls.
-
Constructor Summary
ConstructorsConstructorDescriptionSyncOffloadStickyBucketAdapter(StickyBucketService delegate, Executor executor) -
Method Summary
Modifier and TypeMethodDescriptiongetAllAssignments(Map<String, String> attributes) Look up the documents for all of a user's identifier attributes.getAssignments(String attributeName, String attributeValue) Look up one sticky bucket document.Persist one sticky bucket document (upsert byattributeName + "||" + attributeValue).Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface growthbook.sdk.java.stickyBucketing.AsyncStickyBucketService
getKey
-
Constructor Details
-
SyncOffloadStickyBucketAdapter
- Parameters:
delegate- the blocking service to adaptexecutor- where the delegate's blocking calls run; sized for blocking I/O (never a CPU-sized pool)
-
-
Method Details
-
getAssignments
public CompletionStage<StickyAssignmentsDocument> getAssignments(String attributeName, String attributeValue) Description copied from interface:AsyncStickyBucketServiceLook up one sticky bucket document.- Specified by:
getAssignmentsin interfaceAsyncStickyBucketService- Parameters:
attributeName- the identifier attribute name (e.g.id)attributeValue- the identifier attribute value- Returns:
- a stage completing with the document, or
nullif absent
-
saveAssignments
Description copied from interface:AsyncStickyBucketServicePersist one sticky bucket document (upsert byattributeName + "||" + attributeValue).- Specified by:
saveAssignmentsin interfaceAsyncStickyBucketService- Parameters:
doc- the document to persist- Returns:
- a stage completing when the write is durable
-
getAllAssignments
public CompletionStage<Map<String,StickyAssignmentsDocument>> getAllAssignments(Map<String, String> attributes) Description copied from interface:AsyncStickyBucketServiceLook up the documents for all of a user's identifier attributes.The default implementation fans out one
AsyncStickyBucketService.getAssignments(java.lang.String, java.lang.String)call per attribute. Override it to batch all lookups into a single round trip (e.g. one RedisMGET) — this method is called once per sticky bucket fetch, so batching here is the highest-leverage optimization.- Specified by:
getAllAssignmentsin interfaceAsyncStickyBucketService- Parameters:
attributes- identifier attribute name → value- Returns:
- a stage completing with found documents keyed by
AsyncStickyBucketService.getKey(java.lang.String, java.lang.String); attributes with no document are omitted
-