2
2
//
3
3
// This source file is part of the RediStack open source project
4
4
//
5
- // Copyright (c) 2020 RediStack project authors
5
+ // Copyright (c) 2020-2023 RediStack project authors
6
6
// Licensed under Apache License v2.0
7
7
//
8
8
// See LICENSE.txt for license information
@@ -80,7 +80,7 @@ public class RedisConnectionPool {
80
80
minimumConnectionCount: config. minimumConnectionCount,
81
81
leaky: config. maximumConnectionCount. leaky,
82
82
loop: boundEventLoop,
83
- systemContext : config. poolDefaultLogger,
83
+ backgroundLogger : config. poolDefaultLogger,
84
84
connectionBackoffFactor: config. connectionRetryConfiguration. backoff. factor,
85
85
initialConnectionBackoffDelay: config. connectionRetryConfiguration. backoff. initialDelay,
86
86
connectionFactory: self . connectionFactory ( _: )
@@ -257,11 +257,11 @@ extension RedisConnectionPool: RedisClient {
257
257
public var eventLoop : EventLoop { self . loop }
258
258
259
259
public func logging( to logger: Logger ) -> RedisClient {
260
- return UserContextRedisClient ( client: self , context : self . prepareLoggerForUse ( logger) )
260
+ return UserContextRedisClient ( client: self , logger : self . prepareLoggerForUse ( logger) )
261
261
}
262
262
263
263
public func send( command: String , with arguments: [ RESPValue ] ) -> EventLoopFuture < RESPValue > {
264
- return self . send ( command: command, with: arguments, context : nil )
264
+ return self . send ( command: command, with: arguments, logger : nil )
265
265
}
266
266
267
267
public func subscribe(
@@ -275,7 +275,7 @@ extension RedisConnectionPool: RedisClient {
275
275
messageReceiver: receiver,
276
276
onSubscribe: subscribeHandler,
277
277
onUnsubscribe: unsubscribeHandler,
278
- context : nil
278
+ logger : nil
279
279
)
280
280
}
281
281
@@ -290,33 +290,33 @@ extension RedisConnectionPool: RedisClient {
290
290
messageReceiver: receiver,
291
291
onSubscribe: subscribeHandler,
292
292
onUnsubscribe: unsubscribeHandler,
293
- context : nil
293
+ logger : nil
294
294
)
295
295
}
296
296
297
297
public func unsubscribe( from channels: [ RedisChannelName ] ) -> EventLoopFuture < Void > {
298
- return self . unsubscribe ( from: channels, context : nil )
298
+ return self . unsubscribe ( from: channels, logger : nil )
299
299
}
300
300
301
301
public func punsubscribe( from patterns: [ String ] ) -> EventLoopFuture < Void > {
302
- return self . punsubscribe ( from: patterns, context : nil )
302
+ return self . punsubscribe ( from: patterns, logger : nil )
303
303
}
304
304
}
305
305
306
306
// MARK: RedisClientWithUserContext conformance
307
307
extension RedisConnectionPool : RedisClientWithUserContext {
308
- internal func send( command: String , with arguments: [ RESPValue ] , context : Logger ? ) -> EventLoopFuture < RESPValue > {
308
+ internal func send( command: String , with arguments: [ RESPValue ] , logger : Logger ? ) -> EventLoopFuture < RESPValue > {
309
309
return self . forwardOperationToConnection (
310
310
{ ( connection, returnConnection, context) in
311
311
312
312
connection. sendCommandsImmediately = true
313
313
314
314
return connection
315
- . send ( command: command, with: arguments, context : context)
315
+ . send ( command: command, with: arguments, logger : context)
316
316
. always { _ in returnConnection ( connection, context) }
317
317
} ,
318
318
preferredConnection: nil ,
319
- context: context
319
+ context: logger
320
320
)
321
321
}
322
322
@@ -325,7 +325,7 @@ extension RedisConnectionPool: RedisClientWithUserContext {
325
325
messageReceiver receiver: @escaping RedisSubscriptionMessageReceiver ,
326
326
onSubscribe subscribeHandler: RedisSubscriptionChangeHandler ? ,
327
327
onUnsubscribe unsubscribeHandler: RedisSubscriptionChangeHandler ? ,
328
- context : Context ?
328
+ logger : Logger ?
329
329
) -> EventLoopFuture < Void > {
330
330
return self . subscribe (
331
331
using: {
@@ -334,24 +334,24 @@ extension RedisConnectionPool: RedisClientWithUserContext {
334
334
messageReceiver: receiver,
335
335
onSubscribe: subscribeHandler,
336
336
onUnsubscribe: $1,
337
- context : $2
337
+ logger : $2
338
338
)
339
339
} ,
340
340
onUnsubscribe: unsubscribeHandler,
341
- context: context
341
+ context: logger
342
342
)
343
343
}
344
344
345
- internal func unsubscribe( from channels: [ RedisChannelName ] , context : Context ? ) -> EventLoopFuture < Void > {
346
- return self . unsubscribe ( using: { $0. unsubscribe ( from: channels, context : $1) } , context: context )
345
+ internal func unsubscribe( from channels: [ RedisChannelName ] , logger : Logger ? ) -> EventLoopFuture < Void > {
346
+ return self . unsubscribe ( using: { $0. unsubscribe ( from: channels, logger : $1) } , context: logger )
347
347
}
348
348
349
349
internal func psubscribe(
350
350
to patterns: [ String ] ,
351
351
messageReceiver receiver: @escaping RedisSubscriptionMessageReceiver ,
352
352
onSubscribe subscribeHandler: RedisSubscriptionChangeHandler ? ,
353
353
onUnsubscribe unsubscribeHandler: RedisSubscriptionChangeHandler ? ,
354
- context : Context ?
354
+ logger : Logger ?
355
355
) -> EventLoopFuture < Void > {
356
356
return self . subscribe (
357
357
using: {
@@ -360,22 +360,22 @@ extension RedisConnectionPool: RedisClientWithUserContext {
360
360
messageReceiver: receiver,
361
361
onSubscribe: subscribeHandler,
362
362
onUnsubscribe: $1,
363
- context : $2
363
+ logger : $2
364
364
)
365
365
} ,
366
366
onUnsubscribe: unsubscribeHandler,
367
- context: context
367
+ context: logger
368
368
)
369
369
}
370
370
371
- internal func punsubscribe( from patterns: [ String ] , context : Context ? ) -> EventLoopFuture < Void > {
372
- return self . unsubscribe ( using: { $0. punsubscribe ( from: patterns, context : $1) } , context: context )
371
+ internal func punsubscribe( from patterns: [ String ] , logger : Logger ? ) -> EventLoopFuture < Void > {
372
+ return self . unsubscribe ( using: { $0. punsubscribe ( from: patterns, logger : $1) } , context: logger )
373
373
}
374
374
375
375
private func subscribe(
376
- using operation: @escaping ( RedisConnection , @escaping RedisSubscriptionChangeHandler , Context ) -> EventLoopFuture < Void > ,
376
+ using operation: @escaping ( RedisConnection , @escaping RedisSubscriptionChangeHandler , Logger ) -> EventLoopFuture < Void > ,
377
377
onUnsubscribe unsubscribeHandler: RedisSubscriptionChangeHandler ? ,
378
- context: Context ?
378
+ context: Logger ?
379
379
) -> EventLoopFuture < Void > {
380
380
return self . forwardOperationToConnection (
381
381
{ ( connection, returnConnection, context) in
@@ -406,8 +406,8 @@ extension RedisConnectionPool: RedisClientWithUserContext {
406
406
}
407
407
408
408
private func unsubscribe(
409
- using operation: @escaping ( RedisConnection , Context ) -> EventLoopFuture < Void > ,
410
- context: Context ?
409
+ using operation: @escaping ( RedisConnection , Logger ) -> EventLoopFuture < Void > ,
410
+ context: Logger ?
411
411
) -> EventLoopFuture < Void > {
412
412
return self . forwardOperationToConnection (
413
413
{ ( connection, returnConnection, context) in
@@ -430,9 +430,9 @@ extension RedisConnectionPool: RedisClientWithUserContext {
430
430
431
431
@usableFromInline
432
432
internal func forwardOperationToConnection< T> (
433
- _ operation: @escaping ( RedisConnection , @escaping ( RedisConnection , Context ) -> Void , Context ) -> EventLoopFuture < T > ,
433
+ _ operation: @escaping ( RedisConnection , @escaping ( RedisConnection , Logger ) -> Void , Logger ) -> EventLoopFuture < T > ,
434
434
preferredConnection: RedisConnection ? ,
435
- context: Context ?
435
+ context: Logger ?
436
436
) -> EventLoopFuture < T > {
437
437
// Establish event loop context then jump to the in-loop version.
438
438
guard self . loop. inEventLoop else {
0 commit comments