Async Kotlin client in Java SDK
- Dominant language
- Python
- Stars
- 46.9k
- Forks
- 17.8k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 472
Description
Java doesn’t do coroutines, so the current `Client` implementation is sync. But Kotlin does, and we might benefit from a different async client. I think we can do it like this:
1. Add an AsyncTask protocol that has an `suspend fun execute` instead of the sync execute function.
2. Create an AsyncClient class to use instead of Client. `suspend fun execute(client: AsyncClient, context: Context)`.
3. When the task is executed, check which protocol is used. Wrap `runBlocking` around the async task.
4. Make the annotation processor detect `suspend fun` so the same `@Builder.Task` can be used on both sync and async and automatically does the right thing.
The only question is whether we just add `Async` to both Task and Client. Should the sync version be renamed? (BlockingTask & BlockingClient?)
Contributor guide
Assessment
This issue has not been assessed yet.