我正在使用play-slick。我试图在一个圆滑的DBaction中找回未来,但我失败了:
def test = DBAction(parse.json){ implicit request =>
scala.concurrent.Future {
NotFound(Json.obj("error" -> "some error"))
}
}
[error] found : scala.concurrent.Future[play.api.mvc.Result]
[error] required: play.api.mvc.Result我该如何回报这个未来?Async {}现在在2.3中消失了,DBAction().async (正如文档中所说的用于正常的未来播放动作)似乎不可用。
发布于 2014-08-18 16:26:18
我最近遇到了同样的问题,因为我使用的是Future.firstCompleteOf(数据库调用,超时),而对我来说似乎起作用的是使用DB.withSession。
所以我的控制器操作仍然停留在一个Action.async块中,然后我的未来看起来像这样
Future.firstCompleteOf(Seq(Future(
DB.withSession {implicit session => MyTable.findById(id) } ), timeoutFuture) ).map {
case Whatever => …
}.recoverWith {
case Whatever => …
}https://stackoverflow.com/questions/24526479
复制相似问题