2

如何使用设置连接超时Doobie

现在,我正在创建一个新hikari transactor的,然后对其进行配置:

def buildTransactor(driver: String, uri: String, 
                    user: String, pwd: String, 
                    timeout: Long) = for {
  ce <- ExecutionContexts.fixedThreadPool[Task](10)
  te <- ExecutionContexts.cachedThreadPool[Task]
  xa <- HikariTransactor.newHikariTransactor[Task](
    driver, uri, user, pwd, ce, te)
  _ <- configure(xa, timeout)   // Configure transactor
} yield xa


def configure(xa: HikariTransactor[Task], timeout: Long) = Resource.liftF(
  xa.configure(ds => Task(ds.setConnectionTimeout(timeout)))
)

我不确定是否可以。Docs什么也没说。

4

0 回答 0