Skip to content

Async Kotlin client in Java SDK #67683

@uranusjr

Description

@uranusjr

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?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    AIP-108: java-sdkChange this to an 'area:' label after AIP acceptance.kind:featureFeature Requests
    No fields configured for Feature.

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions