Mic*_*ael 2 concurrency scala http scala-dispatch
我将使用Dispatch编写一个简单的HTTP客户端.我打电话dispatch.Http给未来,并呼吁未来得到回应
val request = ... val future = Http(request) // call the server asynchronously val response = future() // wait for the response from the server
现在我想知道如何等待超时.我想最后一次API调用是:
// throw an exception if no response received within timeout val response = future(timeout: Long)
是否有意义 ?
我理解Dispatch返回scala.concurrent.Future,它不提供API超时.你会如何建议我实施它?
您可以创建配置的Http客户端:
val httpApplicationClient = Http.configure(_.setRequestTimeoutInMs(3000))
val future = httpApplicationClient(request)
...
| 归档时间: |
|
| 查看次数: |
1840 次 |
| 最近记录: |