-
Notifications
You must be signed in to change notification settings - Fork 902
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
Provide an easy way to create an HttpService
from a Kotlin coroutine
#5442
Comments
HttpService
.HttpService
from a Kotlin coroutine
Thanks, @Dogacel for the design. 👍
I believe that we don't have to make it an abstract class as we do for Line 59 in df826c0
Because users don't have to call interface CoroutineHttpService : HttpService {
override fun serve(ctx: ServiceRequestContext, req: HttpRequest): HttpResponse {
return HttpResponse.of(CoroutineScope(ctx.asCoroutineContext()).future { // Do we also need to add user context?
suspendedServe(ctx, req)
})
}
suspend fun suspendedServe(ctx: ServiceRequestContext, req: HttpRequest): HttpResponse
} |
If this risk is something accepted down the line, I'm fine with it 😄.
LGTM 👍 Consistency is desired. |
Thanks! By the way, this issue has been assigned to a participant for our internal sprint. 😉 |
Similar to
CoroutineServerInterceptor
#4669We should have
HttpService
based on coroutines. Currently, only way to implement asuspend
http service is usingAnnotatedService
. In some scenarios, users might want to use theHttpService
orAbstractHttpService
, which in my opinion has more granularly defined signatures which seem less like magic.Sample proposed implementation 1 (inheritance)
Sample proposed implementation 2 (composition)
Ditto for
AbstractHttpService
.Inheritance
Pros:
HttpService
because it inherits.Cons:
serveAsync
orcoServe
.serve
.Composition
Pros:
HttpService
.Cons:
.asHttpService()
method to convert to anHttpService
Also need to check if we lose any valuable method if we don't inherit
HttpService
.The text was updated successfully, but these errors were encountered: