【发布时间】:2022-01-12 20:46:15
【问题描述】:
我正在尝试在协程中使用 vertx 反应式 sql 客户端执行数据库事务。
不知何故,我无法弄清楚如何将 CompletableFuture 转换为所需的 io.vertx.core.Future 类型。是否有任何辅助方法或扩展可以轻松做到这一点?
val client : PgPool
...
suspend fun someServiceFunction () {
coroutineScope {
client.withTransaction { connection ->
val completableFuture = async {
repository.save(connection, requestDTO) //This is a suspend function
}.asCompletableFuture()
//Return type has to be a io.vertx.core.Future
//How can I transform the completableFuture to it ?
}
}
}
感谢您的帮助!
【问题讨论】:
标签: kotlin kotlin-coroutines vert.x vert.x-webclient