Skip to content

Commit

Permalink
remove infix notation in settings impls
Browse files Browse the repository at this point in the history
  • Loading branch information
Synesso committed Sep 5, 2018
1 parent d0c0d1e commit a58a67a
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ private[http] final case class LfuCacheSettingsImpl(
}

object CachingSettings extends SettingsCompanion[CachingSettings]("akka.http.caching") {
def fromSubConfig(root: Config, c: Config) = {
def fromSubConfig(root: Config, c: Config): CachingSettingsImpl = {
val lfuConfig = c.getConfig("lfu-cache")
CachingSettingsImpl(
LfuCacheSettingsImpl(
lfuConfig getInt "max-capacity",
lfuConfig getInt "initial-capacity",
lfuConfig getPotentiallyInfiniteDuration "time-to-live",
lfuConfig getPotentiallyInfiniteDuration "time-to-idle"
lfuConfig.getInt("max-capacity"),
lfuConfig.getInt("initial-capacity"),
lfuConfig.getPotentiallyInfiniteDuration("time-to-live"),
lfuConfig.getPotentiallyInfiniteDuration("time-to-idle")
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ private[akka] object ClientConnectionSettingsImpl extends SettingsCompanion[Clie
val c = inner.withFallback(root.getConfig(prefix))
new ClientConnectionSettingsImpl(
userAgentHeader = c.getString("user-agent-header").toOption.map(`User-Agent`(_)),
connectingTimeout = c getFiniteDuration "connecting-timeout",
idleTimeout = c getPotentiallyInfiniteDuration "idle-timeout",
requestHeaderSizeHint = c getIntBytes "request-header-size-hint",
connectingTimeout = c.getFiniteDuration("connecting-timeout"),
idleTimeout = c.getPotentiallyInfiniteDuration("idle-timeout"),
requestHeaderSizeHint = c.getIntBytes("request-header-size-hint"),
logUnencryptedNetworkBytes = LogUnencryptedNetworkBytes(c getString "log-unencrypted-network-bytes"),
websocketSettings = WebSocketSettingsImpl.client(c.getConfig("websocket")),
socketOptions = SocketOptionSettings.fromSubConfig(root, c.getConfig("socket-options")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@ private[akka] final case class ConnectionPoolSettingsImpl(
}

object ConnectionPoolSettingsImpl extends SettingsCompanion[ConnectionPoolSettingsImpl]("akka.http.host-connection-pool") {
def fromSubConfig(root: Config, c: Config) = {
def fromSubConfig(root: Config, c: Config): ConnectionPoolSettingsImpl = {
new ConnectionPoolSettingsImpl(
c getInt "max-connections",
c getInt "min-connections",
c getInt "max-retries",
c getInt "max-open-requests",
c getInt "pipelining-limit",
c getPotentiallyInfiniteDuration "idle-timeout",
c.getInt("max-connections"),
c.getInt("min-connections"),
c.getInt("max-retries"),
c.getInt("max-open-requests"),
c.getInt("pipelining-limit"),
c.getPotentiallyInfiniteDuration("idle-timeout"),
ClientConnectionSettingsImpl.fromSubConfig(root, c.getConfig("client")),
c.getString("pool-implementation").toLowerCase match {
case "legacy" PoolImplementation.Legacy
case "new" PoolImplementation.New
},
c getPotentiallyInfiniteDuration "response-entity-subscription-timeout"
c.getPotentiallyInfiniteDuration("response-entity-subscription-timeout")
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ private[http] final case class HttpsProxySettingsImpl(
}

object HttpsProxySettingsImpl extends SettingsCompanion[HttpsProxySettingsImpl]("akka.http.client.proxy.https") {
override def fromSubConfig(root: Config, c: Config) = {
override def fromSubConfig(root: Config, c: Config): HttpsProxySettingsImpl = {
new HttpsProxySettingsImpl(
c getString "host",
c getInt "port"
c.getString("host"),
c.getInt("port")
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,33 +64,34 @@ object ParserSettingsImpl extends SettingsCompanion[ParserSettingsImpl]("akka.ht
private[this] val noCustomStatusCodes: Int Option[StatusCode] = ConstantFun.scalaAnyToNone
private[ParserSettingsImpl] val noCustomMediaTypes: (String, String) Option[MediaType] = ConstantFun.scalaAnyTwoToNone

def fromSubConfig(root: Config, inner: Config) = {
def fromSubConfig(root: Config, inner: Config): ParserSettingsImpl = {
val c = inner.withFallback(root.getConfig(prefix))
val cacheConfig = c getConfig "header-cache"

new ParserSettingsImpl(
c getIntBytes "max-uri-length",
c getIntBytes "max-method-length",
c getIntBytes "max-response-reason-length",
c getIntBytes "max-header-name-length",
c getIntBytes "max-header-value-length",
c getIntBytes "max-header-count",
c getPossiblyInfiniteBytes "max-content-length",
c getPossiblyInfiniteBytes "max-to-strict-bytes",
c getIntBytes "max-chunk-ext-length",
c getIntBytes "max-chunk-size",
Uri.ParsingMode(c getString "uri-parsing-mode"),
CookieParsingMode(c getString "cookie-parsing-mode"),
c getBoolean "illegal-header-warnings",
(c getStringList "ignore-illegal-header-for").asScala.map(_.toLowerCase).toSet,
ErrorLoggingVerbosity(c getString "error-logging-verbosity"),
IllegalResponseHeaderValueProcessingMode(c getString "illegal-response-header-value-processing-mode"),
c.getIntBytes("max-uri-length"),
c.getIntBytes("max-method-length"),
c.getIntBytes("max-response-reason-length"),
c.getIntBytes("max-header-name-length"),
c.getIntBytes("max-header-value-length"),
c.getIntBytes("max-header-count"),
c.getPossiblyInfiniteBytes("max-content-length"),
c.getPossiblyInfiniteBytes("max-to-strict-bytes"),
c.getIntBytes("max-chunk-ext-length"),
c.getIntBytes("max-chunk-size"),
Uri.ParsingMode(c.getString("uri-parsing-mode")),
CookieParsingMode(c.getString("cookie-parsing-mode")),
c.getBoolean("illegal-header-warnings"),
c.getStringList("ignore-illegal-header-for").asScala.map(_.toLowerCase).toSet,
ErrorLoggingVerbosity(c.getString("error-logging-verbosity")),
IllegalResponseHeaderValueProcessingMode(c.getString("illegal-response-header-value-processing-mode")),
cacheConfig.entrySet.asScala.map(kvp kvp.getKey cacheConfig.getInt(kvp.getKey))(collection.breakOut),
c getBoolean "tls-session-info-header",
c getBoolean "modeled-header-parsing",
c.getBoolean("tls-session-info-header"),
c.getBoolean("modeled-header-parsing"),
noCustomMethods,
noCustomStatusCodes,
noCustomMediaTypes)
noCustomMediaTypes
)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ private[http] final case class PreviewServerSettingsImpl(

object PreviewServerSettingsImpl extends SettingsCompanion[PreviewServerSettingsImpl]("akka.http.server.preview") {
def fromSubConfig(root: Config, c: Config) = PreviewServerSettingsImpl(
c getBoolean "enable-http2"
c.getBoolean("enable-http2")
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ private[http] final case class RoutingSettingsImpl(

object RoutingSettingsImpl extends SettingsCompanion[RoutingSettingsImpl]("akka.http.routing") {
def fromSubConfig(root: Config, c: Config) = new RoutingSettingsImpl(
c getBoolean "verbose-error-messages",
c getBoolean "file-get-conditional",
c getBoolean "render-vanity-footer",
c getInt "range-count-limit",
c getBytes "range-coalescing-threshold",
c getIntBytes "decode-max-bytes-per-chunk",
c getPossiblyInfiniteBytes "decode-max-size",
c getString "file-io-dispatcher")
c.getBoolean("verbose-error-messages"),
c.getBoolean("file-get-conditional"),
c.getBoolean("render-vanity-footer"),
c.getInt("range-count-limit"),
c.getBytes("range-coalescing-threshold"),
c.getIntBytes("decode-max-bytes-per-chunk"),
c.getPossiblyInfiniteBytes("decode-max-size"),
c.getString("file-io-dispatcher")
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private[http] final case class ServerSentEventSettingsImpl(

object ServerSentEventSettingsImpl extends SettingsCompanion[ServerSentEventSettingsImpl]("akka.http.sse") {
def fromSubConfig(root: Config, c: Config) = ServerSentEventSettingsImpl(
c getInt "max-event-size",
c getInt "max-line-size"
c.getInt("max-event-size"),
c.getInt("max-line-size")
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,22 @@ private[http] object ServerSettingsImpl extends SettingsCompanion[ServerSettings
c.getString("server-header").toOption.map(Server(_)),
PreviewServerSettingsImpl.fromSubConfig(root, c.getConfig("preview")),
Timeouts(
c getPotentiallyInfiniteDuration "idle-timeout",
c getPotentiallyInfiniteDuration "request-timeout",
c getFiniteDuration "bind-timeout",
c getPotentiallyInfiniteDuration "linger-timeout"),
c getInt "max-connections",
c getInt "pipelining-limit",
c getBoolean "remote-address-header",
c getBoolean "raw-request-uri-header",
c getBoolean "transparent-head-requests",
c getBoolean "verbose-error-messages",
c getIntBytes "response-header-size-hint",
c getInt "backlog",
LogUnencryptedNetworkBytes(c getString "log-unencrypted-network-bytes"),
c.getPotentiallyInfiniteDuration("idle-timeout"),
c.getPotentiallyInfiniteDuration("request-timeout"),
c.getFiniteDuration("bind-timeout"),
c.getPotentiallyInfiniteDuration("linger-timeout")),
c.getInt("max-connections"),
c.getInt("pipelining-limit"),
c.getBoolean("remote-address-header"),
c.getBoolean("raw-request-uri-header"),
c.getBoolean("transparent-head-requests"),
c.getBoolean("verbose-error-messages"),
c.getIntBytes("response-header-size-hint"),
c.getInt("backlog"),
LogUnencryptedNetworkBytes(c.getString("log-unencrypted-network-bytes")),
SocketOptionSettings.fromSubConfig(root, c.getConfig("socket-options")),
defaultHostHeader =
HttpHeader.parse("Host", c getString "default-host-header", ParserSettings(root)) match {
HttpHeader.parse("Host", c.getString("default-host-header"), ParserSettings(root)) match {
case HttpHeader.ParsingResult.Ok(x: Host, Nil) x
case result
val info = result.errors.head.withSummary("Configured `default-host-header` is illegal")
Expand All @@ -100,8 +100,8 @@ private[http] object ServerSettingsImpl extends SettingsCompanion[ServerSettings
WebSocketSettingsImpl.server(c.getConfig("websocket")),
ParserSettingsImpl.fromSubConfig(root, c.getConfig("parsing")),
Http2ServerSettings.Http2ServerSettingsImpl.fromSubConfig(root, c.getConfig("http2")),
c getInt "default-http-port",
c getInt "default-https-port",
c.getInt("default-http-port"),
c.getInt("default-https-port"),
terminationDeadlineExceededResponseFrom(c)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ object Http2ServerSettings extends SettingsCompanion[Http2ServerSettings] {

private[http] object Http2ServerSettingsImpl extends akka.http.impl.util.SettingsCompanion[Http2ServerSettingsImpl]("akka.http.server.http2") {
def fromSubConfig(root: Config, c: Config): Http2ServerSettingsImpl = Http2ServerSettingsImpl(
maxConcurrentStreams = c getInt "max-concurrent-streams",
requestEntityChunkSize = c getIntBytes "request-entity-chunk-size",
incomingConnectionLevelBufferSize = c getIntBytes "incoming-connection-level-buffer-size",
incomingStreamLevelBufferSize = c getIntBytes "incoming-stream-level-buffer-size",
maxConcurrentStreams = c.getInt("max-concurrent-streams"),
requestEntityChunkSize = c.getIntBytes("request-entity-chunk-size"),
incomingConnectionLevelBufferSize = c.getIntBytes("incoming-connection-level-buffer-size"),
incomingStreamLevelBufferSize = c.getIntBytes("incoming-stream-level-buffer-size"),
None // no possibility to configure internal settings with config
)
}
Expand Down

0 comments on commit a58a67a

Please sign in to comment.