Skip to content

Commit b4fcda8

Browse files
authored
Add onUnexpectedConnectionClose (#210)
1 parent d24cad7 commit b4fcda8

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ let package = Package(
1313
.library(name: "Redis", targets: ["Redis"])
1414
],
1515
dependencies: [
16-
.package(url: "https://gitlab.com/mordil/RediStack.git", from: "1.1.0"),
16+
.package(url: "https://gitlab.com/swift-server-community/RediStack.git", from: "1.4.1"),
1717
.package(url: "https://github.com/vapor/vapor.git", from: "4.50.0"),
1818
],
1919
targets: [

Sources/Redis/RedisConfiguration.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,22 @@ public struct RedisConfiguration {
2222
public var connectionBackoffFactor: Float32
2323
public var initialConnectionBackoffDelay: TimeAmount
2424
public var connectionRetryTimeout: TimeAmount?
25+
public var onUnexpectedConnectionClose: ((RedisConnection) -> Void)?
2526

2627
public init(
2728
maximumConnectionCount: RedisConnectionPoolSize = .maximumActiveConnections(2),
2829
minimumConnectionCount: Int = 0,
2930
connectionBackoffFactor: Float32 = 2,
3031
initialConnectionBackoffDelay: TimeAmount = .milliseconds(100),
31-
connectionRetryTimeout: TimeAmount? = nil
32+
connectionRetryTimeout: TimeAmount? = nil,
33+
onUnexpectedConnectionClose: ((RedisConnection) -> Void)? = nil
3234
) {
3335
self.maximumConnectionCount = maximumConnectionCount
3436
self.minimumConnectionCount = minimumConnectionCount
3537
self.connectionBackoffFactor = connectionBackoffFactor
3638
self.initialConnectionBackoffDelay = initialConnectionBackoffDelay
3739
self.connectionRetryTimeout = connectionRetryTimeout
40+
self.onUnexpectedConnectionClose = onUnexpectedConnectionClose
3841
}
3942
}
4043

@@ -121,6 +124,7 @@ extension RedisConnectionPool.Configuration {
121124
connectionBackoffFactor: config.pool.connectionBackoffFactor,
122125
initialConnectionBackoffDelay: config.pool.initialConnectionBackoffDelay,
123126
connectionRetryTimeout: config.pool.connectionRetryTimeout,
127+
onUnexpectedConnectionClose: config.pool.onUnexpectedConnectionClose,
124128
poolDefaultLogger: defaultLogger
125129
)
126130
}

0 commit comments

Comments
 (0)