Skip to content

Commit

Permalink
Add idle state handler to configuration (hummingbird-project#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler committed Jan 23, 2023
1 parent ca80b0a commit 9a76e0e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Sources/Hummingbird/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ extension HBApplication {
public let tcpNoDelay: Bool
/// Pipelining ensures that only one http request is processed at one time
public let enableHttpPipelining: Bool
/// Idle state handler setup.
public let idleTimeoutConfiguration: HBHTTPServer.IdleStateHandlerConfiguration?
#if canImport(Network)
/// TLS options for NIO Transport services
public let tlsOptions: TSTLSOptions
Expand Down Expand Up @@ -79,6 +81,7 @@ extension HBApplication {
reuseAddress: Bool = true,
tcpNoDelay: Bool = false,
enableHttpPipelining: Bool = true,
idleTimeoutConfiguration: HBHTTPServer.IdleStateHandlerConfiguration? = nil,
threadPoolSize: Int = 2,
logLevel: Logger.Level? = nil,
noHTTPServer: Bool = false
Expand All @@ -93,6 +96,7 @@ extension HBApplication {
self.reuseAddress = reuseAddress
self.tcpNoDelay = tcpNoDelay
self.enableHttpPipelining = enableHttpPipelining
self.idleTimeoutConfiguration = idleTimeoutConfiguration
#if canImport(Network)
self.tlsOptions = .none
#endif
Expand Down Expand Up @@ -131,6 +135,7 @@ extension HBApplication {
maxStreamingBufferSize: Int = 1 * 1024 * 1024,
reuseAddress: Bool = true,
enableHttpPipelining: Bool = true,
idleTimeoutConfiguration: HBHTTPServer.IdleStateHandlerConfiguration? = nil,
threadPoolSize: Int = 2,
logLevel: Logger.Level? = nil,
noHTTPServer: Bool = false,
Expand All @@ -146,6 +151,7 @@ extension HBApplication {
self.reuseAddress = reuseAddress
self.tcpNoDelay = true // not used by Network framework
self.enableHttpPipelining = enableHttpPipelining
self.idleTimeoutConfiguration = idleTimeoutConfiguration
self.tlsOptions = tlsOptions

self.threadPoolSize = threadPoolSize
Expand All @@ -171,6 +177,7 @@ extension HBApplication {
reuseAddress: Bool? = nil,
tcpNoDelay: Bool? = nil,
enableHttpPipelining: Bool? = nil,
idleTimeoutConfiguration: HBHTTPServer.IdleStateHandlerConfiguration? = nil,
threadPoolSize: Int? = nil,
logLevel: Logger.Level? = nil
) -> Self {
Expand All @@ -183,6 +190,7 @@ extension HBApplication {
reuseAddress: reuseAddress ?? self.reuseAddress,
tcpNoDelay: tcpNoDelay ?? self.tcpNoDelay,
enableHttpPipelining: enableHttpPipelining ?? self.enableHttpPipelining,
idleTimeoutConfiguration: idleTimeoutConfiguration ?? self.idleTimeoutConfiguration,
threadPoolSize: threadPoolSize ?? self.threadPoolSize,
logLevel: logLevel ?? self.logLevel
)
Expand All @@ -198,6 +206,7 @@ extension HBApplication {
maxStreamingBufferSize: self.maxStreamingBufferSize,
reuseAddress: self.reuseAddress,
withPipeliningAssistance: self.enableHttpPipelining,
idleTimeoutConfiguration: self.idleTimeoutConfiguration,
tlsOptions: self.tlsOptions
)
}
Expand All @@ -211,7 +220,8 @@ extension HBApplication {
backlog: self.backlog,
reuseAddress: self.reuseAddress,
tcpNoDelay: self.tcpNoDelay,
withPipeliningAssistance: self.enableHttpPipelining
withPipeliningAssistance: self.enableHttpPipelining,
idleTimeoutConfiguration: self.idleTimeoutConfiguration
)
}
#endif
Expand Down

0 comments on commit 9a76e0e

Please sign in to comment.