@@ -5,7 +5,7 @@ import { _Set, setToArray, ISet } from '../../utils/lang/sets';
55import thenable from '../../utils/promise/thenable' ;
66import timeout from '../../utils/promise/timeout' ;
77
8- const logPrefix = 'storage:redis-adapter: ' ;
8+ const LOG_PREFIX = 'storage:redis-adapter: ' ;
99
1010// If we ever decide to fully wrap every method, there's a Commander.getBuiltinCommands from ioredis.
1111const METHODS_TO_PROMISE_WRAP = [ 'set' , 'exec' , 'del' , 'get' , 'keys' , 'sadd' , 'srem' , 'sismember' , 'smembers' , 'incr' , 'rpush' , 'pipeline' , 'expire' , 'mget' ] ;
@@ -55,16 +55,16 @@ export default class RedisAdapter extends ioredis {
5555 _listenToEvents ( ) {
5656 this . once ( 'ready' , ( ) => {
5757 const commandsCount = this . _notReadyCommandsQueue ? this . _notReadyCommandsQueue . length : 0 ;
58- this . log . info ( logPrefix + `Redis connection established. Queued commands: ${ commandsCount } .` ) ;
58+ this . log . info ( LOG_PREFIX + `Redis connection established. Queued commands: ${ commandsCount } .` ) ;
5959 this . _notReadyCommandsQueue && this . _notReadyCommandsQueue . forEach ( queued => {
60- this . log . info ( logPrefix + `Executing queued ${ queued . name } command.` ) ;
60+ this . log . info ( LOG_PREFIX + `Executing queued ${ queued . name } command.` ) ;
6161 queued . command ( ) . then ( queued . resolve ) . catch ( queued . reject ) ;
6262 } ) ;
6363 // After the SDK is ready for the first time we'll stop queueing commands. This is just so we can keep handling BUR for them.
6464 this . _notReadyCommandsQueue = undefined ;
6565 } ) ;
6666 this . once ( 'close' , ( ) => {
67- this . log . info ( logPrefix + 'Redis connection closed.' ) ;
67+ this . log . info ( LOG_PREFIX + 'Redis connection closed.' ) ;
6868 } ) ;
6969 }
7070
@@ -78,7 +78,7 @@ export default class RedisAdapter extends ioredis {
7878 const params = arguments ;
7979
8080 function commandWrapper ( ) {
81- instance . log . debug ( logPrefix + `Executing ${ method } .` ) ;
81+ instance . log . debug ( LOG_PREFIX + `Executing ${ method } .` ) ;
8282 // Return original method
8383 const result = originalMethod . apply ( instance , params ) ;
8484
@@ -93,7 +93,7 @@ export default class RedisAdapter extends ioredis {
9393 result . then ( cleanUpRunningCommandsCb , cleanUpRunningCommandsCb ) ;
9494
9595 return timeout ( instance . _options . operationTimeout , result ) . catch ( err => {
96- instance . log . error ( logPrefix + `${ method } operation threw an error or exceeded configured timeout of ${ instance . _options . operationTimeout } ms. Message: ${ err } ` ) ;
96+ instance . log . error ( LOG_PREFIX + `${ method } operation threw an error or exceeded configured timeout of ${ instance . _options . operationTimeout } ms. Message: ${ err } ` ) ;
9797 // Handling is not the adapter responsibility.
9898 throw err ;
9999 } ) ;
@@ -126,19 +126,19 @@ export default class RedisAdapter extends ioredis {
126126
127127 setTimeout ( function deferedDisconnect ( ) {
128128 if ( instance . _runningCommands . size > 0 ) {
129- instance . log . info ( logPrefix + `Attempting to disconnect but there are ${ instance . _runningCommands . size } commands still waiting for resolution. Defering disconnection until those finish.` ) ;
129+ instance . log . info ( LOG_PREFIX + `Attempting to disconnect but there are ${ instance . _runningCommands . size } commands still waiting for resolution. Defering disconnection until those finish.` ) ;
130130
131131 Promise . all ( setToArray ( instance . _runningCommands ) )
132132 . then ( ( ) => {
133- instance . log . debug ( logPrefix + 'Pending commands finished successfully, disconnecting.' ) ;
133+ instance . log . debug ( LOG_PREFIX + 'Pending commands finished successfully, disconnecting.' ) ;
134134 originalMethod . apply ( instance , params ) ;
135135 } )
136136 . catch ( e => {
137- instance . log . warn ( logPrefix + `Pending commands finished with error: ${ e } . Proceeding with disconnection.` ) ;
137+ instance . log . warn ( LOG_PREFIX + `Pending commands finished with error: ${ e } . Proceeding with disconnection.` ) ;
138138 originalMethod . apply ( instance , params ) ;
139139 } ) ;
140140 } else {
141- instance . log . debug ( logPrefix + 'No commands pending execution, disconnect.' ) ;
141+ instance . log . debug ( LOG_PREFIX + 'No commands pending execution, disconnect.' ) ;
142142 // Nothing pending, just proceed.
143143 originalMethod . apply ( instance , params ) ;
144144 }
0 commit comments