Skip to content

Conversation

@mfateev
Copy link
Member

@mfateev mfateev commented Dec 29, 2025

Summary

  • Add Async.await(Supplier<Boolean>) and Async.await(Duration, Supplier<Boolean>) methods for non-blocking condition waiting that return a Promise
  • Add comprehensive tests for cancellation behavior and condition exception handling
  • Add cross-reference @see Javadoc tags between Workflow.sleep, Workflow.newTimer, Workflow.await, and Async.await to help developers discover blocking vs non-blocking alternatives

Test plan

  • Unit tests for Async.await() with immediate condition satisfaction
  • Unit tests for timed Async.await() with timeout expiration
  • Unit tests for cancellation behavior (CanceledFailure propagation)
  • Unit tests for condition throwing exceptions
  • All existing AsyncAwaitTest and WorkflowTest tests pass

@mfateev mfateev requested a review from a team as a code owner December 29, 2025 22:13
* expired, or exceptionally with CanceledFailure if the enclosing CancellationScope is
* canceled
*/
Promise<Boolean> awaitAsync(Duration timeout, Supplier<Boolean> unblockCondition);
Copy link
Member

@cretz cretz Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will defer to Java SDK reviewers for PR in general, but I wonder if as part of this review we also need to think about an overload that provides a summary to the timer this creates. Also applies to await and part of me wonders if we can reuse reason in await as timer summary, and add reason here. Or if we should just have an overload of both await and awaitAsync that accepts timer options.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added timerSummary to await

Introduces Async.await() methods that return a Promise instead of blocking,
allowing workflows to wait for conditions asynchronously. This enables
concurrent condition waiting and Promise composition with anyOf/allOf.

Key changes:
- Add Async.await(Supplier<Boolean>) returning Promise<Void>
- Add Async.await(Duration, Supplier<Boolean>) returning Promise<Boolean>
- Implement condition watchers in SyncWorkflowContext evaluated via
  beforeThreadsWakeUp callback in DeterministicRunner
- Support cancellation through CancellationScope
- Add comprehensive tests including chaining, anyOf/allOf, and cancellation
- Add testTimedAsyncAwaitCancellation: verifies cancellation of the timed
  Async.await(Duration, Supplier) variant via CancellationScope
- Add testAsyncAwaitConditionThrows: verifies that exceptions thrown by
  conditions during subsequent evaluations complete the promise exceptionally
Link Workflow.sleep, Workflow.newTimer, Workflow.await, and Async.await
in Javadoc to help developers discover blocking vs non-blocking alternatives.
…it()

Add overloads for await methods that accept AwaitOptions, allowing users
to specify a timer summary that appears in the workflow history UI/CLI.

- Add AwaitOptions class with timerSummary field
- Add Async.await(Duration, AwaitOptions, Supplier) for non-blocking waits
- Add Workflow.await(Duration, AwaitOptions, Supplier) for blocking waits
- Add test validating timer summary is set in workflow history
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants