-
Notifications
You must be signed in to change notification settings - Fork 148
Description
Currently, stories in TOCK must answer synchronously, blocking a thread until completion. However, more and more story handler implementations rely on long-running operations, like API calls and LLM routines. As such, it would be useful to have the possibility of writing an asynchronous story handler, which could perform asynchronous operations before sending a message.
Important
TOCK's existing concurrency management relies on Vert.x to manage threads. To keep backward compatibility and avoid creating too many concurrent threads, the new feature should be based on the existing Executor
interface.
Possible concurrency APIs
We have a few options to manage concurrency in async stories:
- Vert.x tasks: naturally supported, but further exposes Vert.x in our public API. Developers may not be familiar with this API.
CompletableFuture
: already supported inExecutor
. As part of the JDK, developers are likely to be familiar with this API.- Kotlin coroutines: can be bridged from
Executor
usingasCoroutineDispatcher
. Kotlin developers are likely to be familiar with this API, and it is the only one that provides structured concurrency.
I believe we should aim to provide support for Kotlin coroutines, as it is the modern standard for Kotlin applications. What are your thoughts?