Skip to content

Commit 40d73e2

Browse files
committed
Code review: Add internal connectionCreationTimeout
1 parent 6cfd62c commit 40d73e2

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Diff for: Sources/AsyncHTTPClient/ConnectionPool.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ class HTTP1ConnectionProvider {
454454
logger: Logger) -> EventLoopFuture<Channel> {
455455
let connectionID = HTTPConnectionPool.Connection.ID.globalGenerator.next()
456456
let eventLoop = preference.bestEventLoop ?? self.eventLoop
457-
let deadline = NIODeadline.now() + (self.configuration.timeout.connect ?? .seconds(10))
457+
let deadline = .now() + self.configuration.timeout.connectionCreationTimeout
458458
return self.factory.makeHTTP1Channel(
459459
connectionID: connectionID,
460460
deadline: deadline,

Diff for: Sources/AsyncHTTPClient/HTTPClient.swift

+7-1
Original file line numberDiff line numberDiff line change
@@ -832,11 +832,17 @@ extension HTTPClient.Configuration {
832832
public var connect: TimeAmount?
833833
/// Specifies read timeout.
834834
public var read: TimeAmount?
835+
836+
/// internal connection creation timeout. Defaults the connect timeout to always contain a value.
837+
var connectionCreationTimeout: TimeAmount {
838+
self.connect ?? .seconds(10)
839+
}
835840

836841
/// Create timeout.
837842
///
838843
/// - parameters:
839-
/// - connect: `connect` timeout.
844+
/// - connect: `connect` timeout. Will default to 10 seconds, if no value is
845+
/// provided. See `var connectionCreationTimeout`
840846
/// - read: `read` timeout.
841847
public init(connect: TimeAmount? = nil, read: TimeAmount? = nil) {
842848
self.connect = connect

0 commit comments

Comments
 (0)