Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make connection retry timeout default consistent #105

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
) {
Expand All @@ -134,7 +136,7 @@ extension RedisConnectionPool {
self.minimumConnectionCount = minimumConnectionCount
self.connectionRetryConfiguration = (
(initialConnectionBackoffDelay, connectionBackoffFactor),
connectionRetryTimeout ?? .milliseconds(10) // always default to a baseline 10ms
connectionRetryTimeout ?? Self.defaultConnectionRetryTimeout
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a breaking change. Explicitly passing nil currently leads to a timeout of 10ms. We would change that to 60sec. This can lead to unexpected behavior for adopters.

)
self.onUnexpectedConnectionClose = onUnexpectedConnectionClose
self.poolDefaultLogger = poolDefaultLogger ?? .redisBaseConnectionPoolLogger
Expand Down