https://kotlinlang.org logo
#coroutines
Title
# coroutines
b

bdawg.io

12/14/2018, 12:37 AM
I created a library for using coroutines with AWS SDKs. Any code reviews/input would be appreciated! https://github.com/bradynpoulsen/aws-sdk-kotlin-coroutines/
d

dave08

12/14/2018, 8:23 AM
I'm not sure if you could use a reified fun to instantiate the object and use it as a reciever in the request config block. Overall it's a good idea 🙂
Also, I wonder if there's a way to handle cancellation in a longer process, otherwise the you might cancel the scope and end up with requests continuing their work. And the naming is a bit hard, since a suspend fun is not a coroutine, but rather something running in a coroutine, it might be better named awsAwaitResult (like the vert.x coroutines adapters...), and why differentiate the blocking and non-blocking in naming (it's not blocking really if it's on another dispatcher in a pool...)?
b

bdawg.io

12/14/2018, 5:14 PM
I was debating on whether to even expose the blocking variants because the AWS SDK makes it very easy to utilize the async clients instead. That's a good point though since the caller might thing that the blocking name means it blocks their current thread. I intended it to be explicit that you are launching a method that will be blocking your dispatcher's threads when there's async variants provided by all of the AWS SDKs
I renamed those to
suspendCommand
and
suspendCommandAsync
and decided to have the earlier be an extension on
CoroutineScope
to be more consistent with inheriting the dispatcher in Structured Concurrency.
suspendCommandAsync
doesn’t benefit from a scope since it immediately hands-off to an underlying executor service that the AWS SDK manages
2 Views