Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support different coroutine models in workflows and activities #1845

Open
cretz opened this issue Aug 16, 2023 · 1 comment
Open

Support different coroutine models in workflows and activities #1845

cretz opened this issue Aug 16, 2023 · 1 comment
Labels
enhancement User experience

Comments

@cretz
Copy link
Member

cretz commented Aug 16, 2023

Describe the solution you'd like

Need to several things:

  • May need to slightly abstract workflow concurrency impl to support (but may not)
  • Update Kotlin project to add support for Kotlin coroutines in workflows and activities as Kotlin suspend fun calls (may need to be opt-in in some way). There is an internal POC implementation from @mfateev we can leverage here.
  • Create a new Java 21+ only "temporal-virtual-threads" project that uses virtual threads for workflow concurrency and runs activities in virtual threads (may need to be opt-in in some way)

This is kinda a big project, so some discussion should happen first. The above is just speculation about what to do.

@cretz cretz added the enhancement User experience label Aug 16, 2023
@rocketraman
Copy link

rocketraman commented Nov 17, 2023

As a Kotlin user who is getting started with Temporal, I would love to see this. Calls like Workflow.sleep() block a platform thread, which isn't scalable and is annoying in principle even where its not an actual scalability issue :-)

Kotlin coroutines, and more recently with the release of JDK 21 and Java virtual threads, are a perfect solution to this problem as they take up almost no resources while blocked on workflow sleep or activity calls.

I know nothing about the Java SDK internals, but looking at it from the outside in, the most basic abstraction of an async call is a callback. These are easy to bridge to suspending calls in Kotlin, and presumably to Java fibers. So if the SDK exposed async versions of its API that took a callback to resume the workflow execution, this would be easy to turn back into regular synchronous but non-blocking code via coroutines, and presumably fibers.

Issues which are probably duplicates or at least related to this one, based on the search I just did:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement User experience
Projects
None yet
Development

No branches or pull requests

2 participants