Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ internal constructor(
internal val contextSerdeFactory: SerdeFactory,
) : WorkflowContext {

internal val random: RestateRandom =
RestateRandom(handlerContext.request().invocationId().toRandomSeed())

override fun key(): String {
return this.handlerContext.objectKey()
}
Expand Down Expand Up @@ -191,7 +194,7 @@ internal constructor(
}

override fun random(): RestateRandom {
return RestateRandom(handlerContext.request().invocationId().toRandomSeed())
return this.random
}

override fun <T : Any> promise(key: DurablePromiseKey<T>): DurablePromise<T> {
Expand Down
4 changes: 3 additions & 1 deletion sdk-api/src/main/java/dev/restate/sdk/ContextImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ class ContextImpl implements ObjectContext, WorkflowContext {
private final HandlerContext handlerContext;
private final Executor serviceExecutor;
private final SerdeFactory serdeFactory;
private final RestateRandom random;

ContextImpl(HandlerContext handlerContext, Executor serviceExecutor, SerdeFactory serdeFactory) {
this.handlerContext = handlerContext;
this.serviceExecutor = serviceExecutor;
this.serdeFactory = serdeFactory;
this.random = new RestateRandom(this.request().invocationId().toRandomSeed());
}

static void checkNotInsideRun() {
Expand Down Expand Up @@ -275,7 +277,7 @@ public void reject(String reason) {

@Override
public RestateRandom random() {
return new RestateRandom(this.request().invocationId().toRandomSeed());
return this.random;
}

@Override
Expand Down
Loading