Hello, http clients that utilize `java NIO` alread...
# coroutines
d
Hello, http clients that utilize
java NIO
already have asynchronous nature for example Jetty Http Client, asynchttpclient, apache async http client, and etc is it necessary to wrap it with coroutines to do parallel http call ?
d
This is not necessary but wrapping it with coroutine apis gives you other nice features that coroutines give you, like structured concurrency, etc.
d
is it will improve / reduce the performance of http client itself ?
d
Although those clients use non-blocking apis, the methods are still synchronous and suspend the running coroutine. You will need multiple coroutines to run multiple requests in parallel.
You don't necessarily need to spawn those coroutines off the main thread though.
d
I see, thanks for the insight~
s
if they have a callback you can convert them to suspendable functions using suspendCancellableCoroutine { cont -> blahh // oncallback { cont.resume and so on
d
Or Cahnnels, or CompletableDeferred. It won't improve performance. But it will make your code easier to read.