Permalink
Browse files

! can: break out ServerSettings timeout settings into sub case class, c…

…loses #489
  • Loading branch information...
sirthias committed Sep 11, 2013
1 parent fed40e2 commit 9193318854a06c45e5b25253cde158a56fb568d2
@@ -204,6 +204,7 @@ private[can] object HttpServerConnection {
*/
def pipelineStage(settings: ServerSettings, statsHolder: Option[StatsHolder]) = {
import settings._
+ import timeouts._
ServerFrontend(settings) >>
RequestChunkAggregation(requestChunkAggregationLimit) ? (requestChunkAggregationLimit > 0) >>
PipeliningLimiter(pipeliningLimit) ? (pipeliningLimit > 0) >>
@@ -29,9 +29,7 @@ case class ServerSettings(
serverHeader: String,
sslEncryption: Boolean,
pipeliningLimit: Int,
- idleTimeout: Duration,
- requestTimeout: Duration,
- timeoutTimeout: Duration,
+ timeouts: ServerSettings.Timeouts,
reapingCycle: Duration,
statsSupport: Boolean,
remoteAddressHeader: Boolean,
@@ -42,38 +40,47 @@ case class ServerSettings(
verboseErrorMessages: Boolean,
requestChunkAggregationLimit: Int,
responseHeaderSizeHint: Int,
- bindTimeout: Duration,
- unbindTimeout: Duration,
- registrationTimeout: Duration,
defaultHostHeader: Host,
backpressureSettings: Option[BackpressureSettings],
parserSettings: ParserSettings) {
- requirePositive(idleTimeout)
- requirePositive(requestTimeout)
- requirePositive(timeoutTimeout)
- requirePositive(idleTimeout)
+ requirePositive(reapingCycle)
require(0 <= pipeliningLimit && pipeliningLimit <= 128, "pipelining-limit must be >= 0 and <= 128")
require(0 <= requestChunkAggregationLimit && requestChunkAggregationLimit <= Int.MaxValue,
"request-chunk-aggregation-limit must be >= 0 and <= Int.MaxValue")
require(0 <= responseHeaderSizeHint && responseHeaderSizeHint <= Int.MaxValue,
"response-size-hint must be >= 0 and <= Int.MaxValue")
- requirePositive(bindTimeout)
- requirePositive(unbindTimeout)
- requirePositive(registrationTimeout)
-
- require(!requestTimeout.isFinite || idleTimeout > requestTimeout,
- "idle-timeout must be > request-timeout (if the latter is not 'infinite')")
}
object ServerSettings extends SettingsCompanion[ServerSettings]("spray.can.server") {
+ case class Timeouts(idleTimeout: Duration,
+ requestTimeout: Duration,
+ timeoutTimeout: Duration,
+ bindTimeout: Duration,
+ unbindTimeout: Duration,
+ registrationTimeout: Duration) {
+ requirePositive(idleTimeout)
+ requirePositive(requestTimeout)
+ requirePositive(timeoutTimeout)
+ requirePositive(bindTimeout)
+ requirePositive(unbindTimeout)
+ requirePositive(registrationTimeout)
+ require(!requestTimeout.isFinite || idleTimeout > requestTimeout,
+ "idle-timeout must be > request-timeout (if the latter is not 'infinite')")
+ }
+ implicit def timeoutsShortcut(s: ServerSettings): Timeouts = s.timeouts
+
def fromSubConfig(c: Config) = apply(
c getString "server-header",
c getBoolean "ssl-encryption",
c.getString("pipelining-limit") match { case "disabled" 0; case _ c getInt "pipelining-limit" },
- c getDuration "idle-timeout",
- c getDuration "request-timeout",
- c getDuration "timeout-timeout",
+ Timeouts(
+ c getDuration "idle-timeout",
+ c getDuration "request-timeout",
+ c getDuration "timeout-timeout",
+ c getDuration "bind-timeout",
+ c getDuration "unbind-timeout",
+ c getDuration "registration-timeout"),
c getDuration "reaping-cycle",
c getBoolean "stats-support",
c getBoolean "remote-address-header",
@@ -84,9 +91,6 @@ object ServerSettings extends SettingsCompanion[ServerSettings]("spray.can.serve
c getBoolean "verbose-error-messages",
c getBytes "request-chunk-aggregation-limit" toInt,
c getBytes "response-header-size-hint" toInt,
- c getDuration "bind-timeout",
- c getDuration "unbind-timeout",
- c getDuration "registration-timeout",
defaultHostHeader =
HttpParser.parseHeader(RawHeader("Host", c getString "default-host-header")) match {
case Right(x: Host) x

0 comments on commit 9193318

Please sign in to comment.