oshai
11/05/2018, 3:26 PMCompleteableFuture
.
So I thought about converting it to either suspend fun
by using the await
extension.
Another option is to create methods that return Deferred
.
What do you think is a better approach?Zach Klippenstein (he/him) [MOD]
11/05/2018, 5:38 PMoshai
11/05/2018, 6:35 PMdave08
11/05/2018, 8:57 PMsuspendCancellableCoroutine { }
I think that's what await does... since Deferred and async is more for parallel decomposition, not for just suspending on an async api.gildor
11/06/2018, 12:02 AMoshai
11/06/2018, 6:13 AMgildor
11/06/2018, 10:51 AMdave08
11/06/2018, 11:33 AMawait...
in all the names suggests async operations as in the guide, and one using the coroutines version will probably not be using the regular one. Maybe a Connection
class under a coroutines
namespace or something?oshai
11/06/2018, 11:39 AMConnection
. they are in a seperate class but still I want to diffrentiate them somehow from the name of methods in the original interfacedave08
11/06/2018, 11:49 AMinterface
that is implemented for coroutine use, then a regular connection could be "transformed" to that interface. Something like: fun Connection.coroutinesWrapper(): CoroutineConnection = CoroutineConnectionWrapper(this)
. Vert.x does what you're currently doing for its Rx support... along with new generated classes... I think it wasn't so intuitive.oshai
11/06/2018, 12:38 PMdave08
11/06/2018, 4:39 PMinterface
for it for mocking/testing purposes and also in suspend fun <A> inTransaction(f: (Connection) -> CompletableFuture<A>): A = connection.inTransaction(f).await()
it seems funny that there's a CompletableFuture
there... I think they shouldn't be mixed in here... @oshaisuspend fun <A> inTransaction(f: suspend (Connection) -> A): A
oshai
11/06/2018, 4:42 PMdave08
11/06/2018, 4:50 PMclass SuspendableConnection(val connection: Connection) { ... }
with the actual implementation, and not have val connection
inside the interface at all... unless you think someone would need the original Connection instance? @oshai And what about the inTransaction
with the CompletableFuture
?oshai
11/06/2018, 4:58 PMdave08
11/06/2018, 5:00 PMoshai
11/06/2018, 5:06 PMdave08
11/06/2018, 5:20 PMinTransaction
is used, so I can't give you advice on it too much.. who passes that CompletableFuture
to the lambda f
it receives...?A
?oshai
11/06/2018, 5:44 PMinTransaction
is much more cleardave08
11/06/2018, 5:49 PMDeferred.asCompletableFuture
š, the code would have been MUCH simpler...oshai
11/06/2018, 5:52 PMdave08
11/06/2018, 5:54 PMinTransaction
is not dependant on Mysql or Postgres specifics... it seems like you implemented them in each one individually..?oshai
11/06/2018, 6:49 PM