apache / apache/airflow

Async Kotlin client in Java SDK

Open
#67,683 5 comments 0 reactions 0 assignees View on GitHub
area:java-sdk kind:feature
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.