From 2eb9f0a0dbfcf6fd559236e790713d8127f5855c Mon Sep 17 00:00:00 2001 From: Rick M Date: Wed, 20 Mar 2024 15:02:46 -0700 Subject: [PATCH 1/2] Make connection retry timeout default consistent Makes the connection retry timeout consistent regardless of whether no value is specified, or `nil` is specified. --- .../ConnectionPool/RedisConnectionPool+Configuration.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/RediStack/ConnectionPool/RedisConnectionPool+Configuration.swift b/Sources/RediStack/ConnectionPool/RedisConnectionPool+Configuration.swift index 841cd8d..d302411 100644 --- a/Sources/RediStack/ConnectionPool/RedisConnectionPool+Configuration.swift +++ b/Sources/RediStack/ConnectionPool/RedisConnectionPool+Configuration.swift @@ -83,6 +83,8 @@ extension RedisConnectionPool { /// A configuration object for connection pools. /// - Warning: This type has **reference** semantics due to `ConnectionFactoryConfiguration`. public struct Configuration { + /// The default connection retry timeout + public static let defaultConnectionRetryTimeout: TimeAmount = .seconds(60) /// The set of Redis servers to which this pool is initially willing to connect. public let initialConnectionAddresses: [SocketAddress] /// The minimum number of connections to preserve in the pool. @@ -124,7 +126,7 @@ extension RedisConnectionPool { minimumConnectionCount: Int = 1, connectionBackoffFactor: Float32 = 2, initialConnectionBackoffDelay: TimeAmount = .milliseconds(100), - connectionRetryTimeout: TimeAmount? = .seconds(60), + connectionRetryTimeout: TimeAmount? = defaultConnectionRetryTimeout, onUnexpectedConnectionClose: ((RedisConnection) -> Void)? = nil, poolDefaultLogger: Logger? = nil ) { @@ -134,7 +136,7 @@ extension RedisConnectionPool { self.minimumConnectionCount = minimumConnectionCount self.connectionRetryConfiguration = ( (initialConnectionBackoffDelay, connectionBackoffFactor), - connectionRetryTimeout ?? .milliseconds(10) // always default to a baseline 10ms + connectionRetryTimeout ?? defaultConnectionRetryTimeout ) self.onUnexpectedConnectionClose = onUnexpectedConnectionClose self.poolDefaultLogger = poolDefaultLogger ?? .redisBaseConnectionPoolLogger From 4885c95eee0b1d62abe4774d9ccf6b3a424376c1 Mon Sep 17 00:00:00 2001 From: Rick M Date: Fri, 26 Apr 2024 13:40:03 -0700 Subject: [PATCH 2/2] Fix compile error referencing static member --- .../ConnectionPool/RedisConnectionPool+Configuration.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/RediStack/ConnectionPool/RedisConnectionPool+Configuration.swift b/Sources/RediStack/ConnectionPool/RedisConnectionPool+Configuration.swift index d302411..805c02d 100644 --- a/Sources/RediStack/ConnectionPool/RedisConnectionPool+Configuration.swift +++ b/Sources/RediStack/ConnectionPool/RedisConnectionPool+Configuration.swift @@ -136,7 +136,7 @@ extension RedisConnectionPool { self.minimumConnectionCount = minimumConnectionCount self.connectionRetryConfiguration = ( (initialConnectionBackoffDelay, connectionBackoffFactor), - connectionRetryTimeout ?? defaultConnectionRetryTimeout + connectionRetryTimeout ?? Self.defaultConnectionRetryTimeout ) self.onUnexpectedConnectionClose = onUnexpectedConnectionClose self.poolDefaultLogger = poolDefaultLogger ?? .redisBaseConnectionPoolLogger