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?oshai
11/05/2018, 3:26 PMoshai
11/05/2018, 3:26 PMZach 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 AMoshai
11/06/2018, 8:36 AMoshai
11/06/2018, 8:36 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 PMoshai
11/06/2018, 4:36 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... @oshaidave08
11/06/2018, 4:42 PMsuspend fun <A> inTransaction(f: suspend (Connection) -> A): Aoshai
11/06/2018, 4:42 PMoshai
11/06/2018, 4:45 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?dave08
11/06/2018, 4:52 PMoshai
11/06/2018, 4:58 PMdave08
11/06/2018, 5:00 PMoshai
11/06/2018, 5:06 PMoshai
11/06/2018, 5:06 PMoshai
11/06/2018, 5:14 PMdave08
11/06/2018, 5:20 PMdave08
11/06/2018, 5:25 PMdave08
11/06/2018, 5:29 PMinTransaction is used, so I can't give you advice on it too much.. who passes that CompletableFuture to the lambda f it receives...?dave08
11/06/2018, 5:30 PMA?oshai
11/06/2018, 5:44 PMoshai
11/06/2018, 5:46 PMinTransaction is much more cleardave08
11/06/2018, 5:49 PMDeferred.asCompletableFuture 🙃, the code would have been MUCH simpler...dave08
11/06/2018, 5:50 PMoshai
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