Skip to content

Commit a810ec1

Browse files
When do progress replies with either read from input, or wait pending run, i shall wait for the first of the two to happen.
1 parent 1acc60e commit a810ec1

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

sdk-core/src/main/java/dev/restate/sdk/core/HandlerContextImpl.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -410,17 +410,15 @@ private void pollAsyncResultInner(AsyncResultInternal<?> asyncResult) {
410410

411411
if (response instanceof StateMachine.DoProgressResponse.AnyCompleted) {
412412
// Let it loop now
413-
} else if (response instanceof StateMachine.DoProgressResponse.ReadFromInput) {
414-
this.stateMachine
415-
.waitNextInputSignal()
413+
} else if (response instanceof StateMachine.DoProgressResponse.ReadFromInput
414+
|| response instanceof StateMachine.DoProgressResponse.WaitingPendingRun) {
415+
CompletableFuture.anyOf(
416+
this.waitNextProcessedRun(), this.stateMachine.waitNextInputSignal())
416417
.thenAccept(v -> this.pollAsyncResultInner(asyncResult));
417418
return;
418419
} else if (response instanceof StateMachine.DoProgressResponse.ExecuteRun) {
419420
triggerScheduledRun(((StateMachine.DoProgressResponse.ExecuteRun) response).handle());
420421
// Let it loop now
421-
} else if (response instanceof StateMachine.DoProgressResponse.WaitingPendingRun) {
422-
this.waitNextProcessedRun().thenAccept(v -> this.pollAsyncResultInner(asyncResult));
423-
return;
424422
}
425423
}
426424
}

0 commit comments

Comments
 (0)