Permalink
Browse files

1. Eliminates underlying client's default request timeout which

interferes with streaming API consumption.

2. Provides a method Http#configure for altering the client
configuration.

Fixes #30
  • Loading branch information...
1 parent 1761e23 commit 3fefb2e4d6dd3b1fa50478161ab6fb5dcf3871bc @n8han n8han committed Nov 1, 2012
Showing with 13 additions and 1 deletion.
  1. +13 −1 core/src/main/scala/execution.scala
@@ -15,13 +15,24 @@ case class Http(
promiseExecutor: juc.Executor = Defaults.promiseExecutor,
timer: Timer = Defaults.timer
) extends HttpExecutor {
+ import AsyncHttpClientConfig.Builder
+
/** Convenience method for an Executor with the given timeout */
def waiting(t: Duration) = copy(timeout=t)
/** Convenience method for an executor with a fixed thread pool of
the given size */
def threads(promiseThreadPoolSize: Int) =
copy(promiseExecutor = DaemonThreads(promiseThreadPoolSize))
+
+ /** Replaces `client` with a new instance configured using the withBuilder
+ function. The current client config is the builder's prototype. */
+ def configure(withBuilder: Builder => Builder) =
+ copy(client =
+ new AsyncHttpClient(withBuilder(
+ new AsyncHttpClientConfig.Builder(client.getConfig)
+ ).build)
+ )
}
/** Singleton default Http executor, can be used directly or altered
@@ -41,7 +52,8 @@ private [dispatch] object Defaults {
new NettyAsyncHttpProviderConfig().addProperty(
NettyAsyncHttpProviderConfig.BOSS_EXECUTOR_SERVICE, bossExecutor
)
- ).build()
+ ).setRequestTimeoutInMs(-1) // don't timeout streaming connections
+ .build
lazy val bossExecutor =
juc.Executors.newCachedThreadPool(DaemonThreads.factory)
lazy val promiseExecutor = DaemonThreads(256)

0 comments on commit 3fefb2e

Please sign in to comment.