!htc #19514 more case class => class boilerplate
This commit is contained in:
parent
9b4b68f0c9
commit
244c52c226
6 changed files with 280 additions and 2 deletions
|
|
@ -30,6 +30,35 @@ final class ClientConnectionSettings(
|
|||
|
||||
require(connectingTimeout >= Duration.Zero, "connectingTimeout must be >= 0")
|
||||
require(requestHeaderSizeHint > 0, "request-size-hint must be > 0")
|
||||
|
||||
def copy(
|
||||
userAgentHeader: Option[`User-Agent`] = userAgentHeader,
|
||||
connectingTimeout: FiniteDuration = connectingTimeout,
|
||||
idleTimeout: Duration = idleTimeout,
|
||||
requestHeaderSizeHint: Int = requestHeaderSizeHint,
|
||||
websocketRandomFactory: () ⇒ Random = websocketRandomFactory,
|
||||
socketOptions: immutable.Traversable[SocketOption] = socketOptions,
|
||||
parserSettings: ParserSettings = parserSettings) =
|
||||
new ClientConnectionSettings(
|
||||
userAgentHeader = userAgentHeader,
|
||||
connectingTimeout = connectingTimeout,
|
||||
idleTimeout = idleTimeout,
|
||||
requestHeaderSizeHint = requestHeaderSizeHint,
|
||||
websocketRandomFactory = websocketRandomFactory,
|
||||
socketOptions = socketOptions,
|
||||
parserSettings = parserSettings)
|
||||
|
||||
override def toString = {
|
||||
getClass.getSimpleName + "(" +
|
||||
userAgentHeader + "," +
|
||||
connectingTimeout + "," +
|
||||
idleTimeout + "," +
|
||||
requestHeaderSizeHint + "," +
|
||||
websocketRandomFactory + "," +
|
||||
socketOptions + "," +
|
||||
parserSettings + "," +
|
||||
")"
|
||||
}
|
||||
}
|
||||
|
||||
object ClientConnectionSettings extends SettingsCompanion[ClientConnectionSettings]("akka.http.client") {
|
||||
|
|
@ -68,4 +97,22 @@ object ClientConnectionSettings extends SettingsCompanion[ClientConnectionSettin
|
|||
* Java API
|
||||
*/
|
||||
def create(configOverrides: String): ClientConnectionSettings = ClientConnectionSettings(configOverrides)
|
||||
|
||||
def apply(
|
||||
userAgentHeader: Option[`User-Agent`],
|
||||
connectingTimeout: FiniteDuration,
|
||||
idleTimeout: Duration,
|
||||
requestHeaderSizeHint: Int,
|
||||
websocketRandomFactory: () ⇒ Random,
|
||||
socketOptions: immutable.Traversable[SocketOption],
|
||||
parserSettings: ParserSettings) =
|
||||
new ClientConnectionSettings(
|
||||
userAgentHeader = userAgentHeader,
|
||||
connectingTimeout = connectingTimeout,
|
||||
idleTimeout = idleTimeout,
|
||||
requestHeaderSizeHint = requestHeaderSizeHint,
|
||||
websocketRandomFactory = websocketRandomFactory,
|
||||
socketOptions = socketOptions,
|
||||
parserSettings = parserSettings)
|
||||
|
||||
}
|
||||
|
|
@ -40,6 +40,33 @@ final class ConnectionPoolSettings(
|
|||
require(maxOpenRequests > 0 && (maxOpenRequests & (maxOpenRequests - 1)) == 0, "max-open-requests must be a power of 2 > 0")
|
||||
require(pipeliningLimit > 0, "pipelining-limit must be > 0")
|
||||
require(idleTimeout >= Duration.Zero, "idle-timeout must be >= 0")
|
||||
|
||||
def copy(
|
||||
maxConnections: Int = maxConnections,
|
||||
maxRetries: Int = maxRetries,
|
||||
maxOpenRequests: Int = maxOpenRequests,
|
||||
pipeliningLimit: Int = pipeliningLimit,
|
||||
idleTimeout: Duration = idleTimeout,
|
||||
connectionSettings: ClientConnectionSettings = connectionSettings) =
|
||||
new ConnectionPoolSettings(
|
||||
maxConnections = maxConnections,
|
||||
maxRetries = maxRetries,
|
||||
maxOpenRequests = maxOpenRequests,
|
||||
pipeliningLimit = pipeliningLimit,
|
||||
idleTimeout = idleTimeout,
|
||||
connectionSettings = connectionSettings)
|
||||
|
||||
// TODO we should automate generating those
|
||||
override def toString = {
|
||||
getClass.getSimpleName + "(" +
|
||||
maxConnections + "," +
|
||||
maxRetries + "," +
|
||||
maxOpenRequests + "," +
|
||||
pipeliningLimit + "," +
|
||||
idleTimeout + "," +
|
||||
connectionSettings +
|
||||
")"
|
||||
}
|
||||
}
|
||||
|
||||
object ConnectionPoolSettings extends SettingsCompanion[ConnectionPoolSettings]("akka.http.host-connection-pool") {
|
||||
|
|
@ -76,4 +103,19 @@ object ConnectionPoolSettings extends SettingsCompanion[ConnectionPoolSettings](
|
|||
* Java API
|
||||
*/
|
||||
def create(configOverrides: String): ConnectionPoolSettings = ConnectionPoolSettings(configOverrides)
|
||||
|
||||
def apply(
|
||||
maxConnections: Int,
|
||||
maxRetries: Int,
|
||||
maxOpenRequests: Int,
|
||||
pipeliningLimit: Int,
|
||||
idleTimeout: Duration,
|
||||
connectionSettings: ClientConnectionSettings) =
|
||||
new ConnectionPoolSettings(
|
||||
maxConnections: Int,
|
||||
maxRetries: Int,
|
||||
maxOpenRequests: Int,
|
||||
pipeliningLimit: Int,
|
||||
idleTimeout: Duration,
|
||||
connectionSettings: ClientConnectionSettings)
|
||||
}
|
||||
|
|
@ -90,6 +90,29 @@ final class ParserSettings(
|
|||
includeTlsSessionInfoHeader,
|
||||
customMethods,
|
||||
customStatusCodes)
|
||||
|
||||
// TODO we should automate generating those
|
||||
override def toString = {
|
||||
getClass.getSimpleName + "(" +
|
||||
maxUriLength + "," +
|
||||
maxMethodLength + "," +
|
||||
maxResponseReasonLength + "," +
|
||||
maxHeaderNameLength + "," +
|
||||
maxHeaderValueLength + "," +
|
||||
maxHeaderCount + "," +
|
||||
maxContentLength + "," +
|
||||
maxChunkExtLength + "," +
|
||||
maxChunkSize + "," +
|
||||
uriParsingMode + "," +
|
||||
cookieParsingMode + "," +
|
||||
illegalHeaderWarnings + "," +
|
||||
errorLoggingVerbosity + "," +
|
||||
headerValueCacheLimits + "," +
|
||||
includeTlsSessionInfoHeader + "," +
|
||||
customMethods + "," +
|
||||
customStatusCodes +
|
||||
")"
|
||||
}
|
||||
}
|
||||
|
||||
object ParserSettings extends SettingsCompanion[ParserSettings]("akka.http.parsing") {
|
||||
|
|
@ -97,7 +120,7 @@ object ParserSettings extends SettingsCompanion[ParserSettings]("akka.http.parsi
|
|||
val c = inner.withFallback(root.getConfig(prefix))
|
||||
val cacheConfig = c getConfig "header-cache"
|
||||
|
||||
new ParserSettings(
|
||||
ParserSettings(
|
||||
c getIntBytes "max-uri-length",
|
||||
c getIntBytes "max-method-length",
|
||||
c getIntBytes "max-response-reason-length",
|
||||
|
|
@ -169,5 +192,40 @@ object ParserSettings extends SettingsCompanion[ParserSettings]("akka.http.parsi
|
|||
|
||||
implicit def default(implicit refFactory: ActorRefFactory): ParserSettings =
|
||||
apply(actorSystem)
|
||||
|
||||
def apply(maxUriLength: Int,
|
||||
maxMethodLength: Int,
|
||||
maxResponseReasonLength: Int,
|
||||
maxHeaderNameLength: Int,
|
||||
maxHeaderValueLength: Int,
|
||||
maxHeaderCount: Int,
|
||||
maxContentLength: Long,
|
||||
maxChunkExtLength: Int,
|
||||
maxChunkSize: Int,
|
||||
uriParsingMode: Uri.ParsingMode,
|
||||
cookieParsingMode: ParserSettings.CookieParsingMode,
|
||||
illegalHeaderWarnings: Boolean,
|
||||
errorLoggingVerbosity: ParserSettings.ErrorLoggingVerbosity,
|
||||
headerValueCacheLimits: Map[String, Int],
|
||||
includeTlsSessionInfoHeader: Boolean,
|
||||
customMethods: String ⇒ Option[HttpMethod],
|
||||
customStatusCodes: Int ⇒ Option[StatusCode]): ParserSettings =
|
||||
new ParserSettings(maxUriLength,
|
||||
maxMethodLength,
|
||||
maxResponseReasonLength,
|
||||
maxHeaderNameLength,
|
||||
maxHeaderValueLength,
|
||||
maxHeaderCount,
|
||||
maxContentLength,
|
||||
maxChunkExtLength,
|
||||
maxChunkSize,
|
||||
uriParsingMode,
|
||||
cookieParsingMode,
|
||||
illegalHeaderWarnings,
|
||||
errorLoggingVerbosity,
|
||||
headerValueCacheLimits,
|
||||
includeTlsSessionInfoHeader,
|
||||
customMethods,
|
||||
customStatusCodes)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,58 @@ final class ServerSettings(
|
|||
require(0 < pipeliningLimit && pipeliningLimit <= 1024, "pipelining-limit must be > 0 and <= 1024")
|
||||
require(0 < responseHeaderSizeHint, "response-size-hint must be > 0")
|
||||
require(0 < backlog, "backlog must be > 0")
|
||||
|
||||
def copy(
|
||||
serverHeader: Option[Server] = serverHeader,
|
||||
timeouts: ServerSettings.Timeouts = timeouts,
|
||||
maxConnections: Int = maxConnections,
|
||||
pipeliningLimit: Int = pipeliningLimit,
|
||||
remoteAddressHeader: Boolean = remoteAddressHeader,
|
||||
rawRequestUriHeader: Boolean = rawRequestUriHeader,
|
||||
transparentHeadRequests: Boolean = transparentHeadRequests,
|
||||
verboseErrorMessages: Boolean = verboseErrorMessages,
|
||||
responseHeaderSizeHint: Int = responseHeaderSizeHint,
|
||||
backlog: Int = backlog,
|
||||
socketOptions: immutable.Traversable[SocketOption] = socketOptions,
|
||||
defaultHostHeader: Host = defaultHostHeader,
|
||||
websocketRandomFactory: () ⇒ Random = websocketRandomFactory,
|
||||
parserSettings: ParserSettings = parserSettings) =
|
||||
new ServerSettings(
|
||||
serverHeader = serverHeader,
|
||||
timeouts = timeouts,
|
||||
maxConnections = maxConnections,
|
||||
pipeliningLimit = pipeliningLimit,
|
||||
remoteAddressHeader = remoteAddressHeader,
|
||||
rawRequestUriHeader = rawRequestUriHeader,
|
||||
transparentHeadRequests = transparentHeadRequests,
|
||||
verboseErrorMessages = verboseErrorMessages,
|
||||
responseHeaderSizeHint = responseHeaderSizeHint,
|
||||
backlog = backlog,
|
||||
socketOptions = socketOptions,
|
||||
defaultHostHeader = defaultHostHeader,
|
||||
websocketRandomFactory = websocketRandomFactory,
|
||||
parserSettings = parserSettings)
|
||||
|
||||
// TODO we should automate generating those
|
||||
override def toString: String = {
|
||||
getClass.getSimpleName + "(" +
|
||||
serverHeader + "," +
|
||||
timeouts + "," +
|
||||
maxConnections + "," +
|
||||
pipeliningLimit + "," +
|
||||
remoteAddressHeader + "," +
|
||||
rawRequestUriHeader + "," +
|
||||
transparentHeadRequests + "," +
|
||||
verboseErrorMessages + "," +
|
||||
responseHeaderSizeHint + "," +
|
||||
backlog + "," +
|
||||
socketOptions + "," +
|
||||
defaultHostHeader + "," +
|
||||
websocketRandomFactory + "," +
|
||||
parserSettings + "," +
|
||||
")"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
object ServerSettings extends SettingsCompanion[ServerSettings]("akka.http.server") {
|
||||
|
|
@ -52,6 +104,23 @@ object ServerSettings extends SettingsCompanion[ServerSettings]("akka.http.serve
|
|||
require(idleTimeout > Duration.Zero, "idleTimeout must be infinite or > 0")
|
||||
require(requestTimeout > Duration.Zero, "requestTimeout must be infinite or > 0")
|
||||
require(bindTimeout > Duration.Zero, "bindTimeout must be > 0")
|
||||
|
||||
def copy(
|
||||
idleTimeout: Duration = idleTimeout,
|
||||
requestTimeout: Duration = requestTimeout,
|
||||
bindTimeout: FiniteDuration = bindTimeout) =
|
||||
new Timeouts(
|
||||
idleTimeout,
|
||||
requestTimeout,
|
||||
bindTimeout)
|
||||
|
||||
override def toString = {
|
||||
"Timeouts(" +
|
||||
idleTimeout + "," +
|
||||
requestTimeout + "," +
|
||||
bindTimeout + "," +
|
||||
")"
|
||||
}
|
||||
}
|
||||
implicit def timeoutsShortcut(s: ServerSettings): Timeouts = s.timeouts
|
||||
|
||||
|
|
@ -106,5 +175,37 @@ object ServerSettings extends SettingsCompanion[ServerSettings]("akka.http.serve
|
|||
* Java API
|
||||
*/
|
||||
def create(configOverrides: String): ServerSettings = ServerSettings(configOverrides)
|
||||
|
||||
def apply(
|
||||
serverHeader: Option[Server],
|
||||
timeouts: ServerSettings.Timeouts,
|
||||
maxConnections: Int,
|
||||
pipeliningLimit: Int,
|
||||
remoteAddressHeader: Boolean,
|
||||
rawRequestUriHeader: Boolean,
|
||||
transparentHeadRequests: Boolean,
|
||||
verboseErrorMessages: Boolean,
|
||||
responseHeaderSizeHint: Int,
|
||||
backlog: Int,
|
||||
socketOptions: immutable.Traversable[SocketOption],
|
||||
defaultHostHeader: Host,
|
||||
websocketRandomFactory: () ⇒ Random,
|
||||
parserSettings: ParserSettings) =
|
||||
new ServerSettings(
|
||||
serverHeader = serverHeader,
|
||||
timeouts = timeouts,
|
||||
maxConnections = maxConnections,
|
||||
pipeliningLimit = pipeliningLimit,
|
||||
remoteAddressHeader = remoteAddressHeader,
|
||||
rawRequestUriHeader = rawRequestUriHeader,
|
||||
transparentHeadRequests = transparentHeadRequests,
|
||||
verboseErrorMessages = verboseErrorMessages,
|
||||
responseHeaderSizeHint = responseHeaderSizeHint,
|
||||
backlog = backlog,
|
||||
socketOptions = socketOptions,
|
||||
defaultHostHeader = defaultHostHeader,
|
||||
websocketRandomFactory = websocketRandomFactory,
|
||||
parserSettings = parserSettings)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -326,7 +326,7 @@ class ConnectionPoolSpec extends AkkaSpec("""
|
|||
pipeliningLimit: Int = 1,
|
||||
idleTimeout: Duration = 5.seconds,
|
||||
ccSettings: ClientConnectionSettings = ClientConnectionSettings(system)) = {
|
||||
val settings = ConnectionPoolSettings(maxConnections, maxRetries, maxOpenRequests, pipeliningLimit,
|
||||
val settings = new ConnectionPoolSettings(maxConnections, maxRetries, maxOpenRequests, pipeliningLimit,
|
||||
idleTimeout, ClientConnectionSettings(system))
|
||||
flowTestBench(Http().cachedHostConnectionPool[T](serverHostName, serverPort, settings))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue