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

Generate Mutiny wrapper for Async Clients #998

Open
cthiebault opened this issue Nov 17, 2023 · 6 comments
Open

Generate Mutiny wrapper for Async Clients #998

cthiebault opened this issue Nov 17, 2023 · 6 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@cthiebault
Copy link
Contributor

It would be great to have some Mutiny wrappers for AWS Async Client that return some Uni instead of CompletionStage.

There is already that for Vert.x: io.vertx.mutiny.core.eventbus.EventBus is a wrapper for io.vertx.core.eventbus.EventBus

That would avoid us to write things like (in Kotlin):

fun S3AsyncClient.headObjectUni(headObjectRequest: HeadObjectRequest): Uni<HeadObjectResponse> =
  Uni.createFrom().completionStage(
    headObject(headObjectRequest)
  )
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Jan 17, 2024
@scrocquesel scrocquesel added enhancement New feature or request help wanted Extra attention is needed and removed stale labels Jan 26, 2024
@adampoplawski
Copy link
Contributor

adampoplawski commented Oct 4, 2024

@scrocquesel I would like to contribute here. I have a question. Do you think it would be good idea, to not only change type from CompletionStage to Uni but also handle context switching?

quarkusio/quarkus#34687

https://quarkusio.zulipchat.com/#narrow/stream/187030-users/topic/.E2.9C.94.20Disappearing.20MDC.20context.20for.20logs.20between.20vert.2Ex.20and.20mu.2E.2E.2E

This would (to my understanding) fix those 2 issues

@scrocquesel
Copy link
Member

We don't have control on the signature of the amazon async client.
We could provide helper methods or find a way to generate a MutinyAsyncClient from the AsyncClient.

@scrocquesel
Copy link
Member

Context switching is another beast I don't know how to tackle. The issue is that we could have interceptor that will be call by the AWS SDK. I guess we would need to find a way to force the AWS SDK to continue on a context aware thread or capture/restore the thread context. Otherwise, having it handled in the mutiny wrapper at a slightly higher level would be a good start and fill 90% user use cases.

@adampoplawski
Copy link
Contributor

I was aiming to provide at least helper method that will handle sth like

fun toUni(keyBuilder: (Key.Builder) -> Unit): Uni<TestItem> {
    val context = VertxContext.getOrCreateDuplicatedContext()

    return Uni.createFrom().completionStage { table.getItem { it.key(keyBuilder)} }
        .emitOn { r -> context.runOnContext { _ -> r.run() } }
}

to get both Uni type and context switch

@adampoplawski
Copy link
Contributor

@scrocquesel
I think I can take this as next contribution. As in post above I think utils method, that is transforming CompletableFuture to Uni and emitting on restored context may be useful. Any thoughts on that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants