@@ -135,13 +135,6 @@ Cluster.prototype.resetNodesRefreshInterval = function () {
135
135
* @public
136
136
*/
137
137
Cluster . prototype . connect = function ( ) {
138
- function readyHandler ( ) {
139
- this . setStatus ( 'ready' ) ;
140
- this . retryAttempts = 0 ;
141
- this . executeOfflineCommands ( ) ;
142
- this . resetNodesRefreshInterval ( ) ;
143
- }
144
-
145
138
var Promise = PromiseContainer . get ( ) ;
146
139
return new Promise ( function ( resolve , reject ) {
147
140
if ( this . status === 'connecting' || this . status === 'connect' || this . status === 'ready' ) {
@@ -156,6 +149,14 @@ Cluster.prototype.connect = function () {
156
149
157
150
this . connectionPool . reset ( this . startupNodes ) ;
158
151
152
+ function readyHandler ( ) {
153
+ this . setStatus ( 'ready' ) ;
154
+ this . retryAttempts = 0 ;
155
+ this . executeOfflineCommands ( ) ;
156
+ this . resetNodesRefreshInterval ( ) ;
157
+ resolve ( ) ;
158
+ }
159
+
159
160
var closeListener ;
160
161
var refreshListener = function ( ) {
161
162
this . removeListener ( 'close' , closeListener ) ;
@@ -164,7 +165,7 @@ Cluster.prototype.connect = function () {
164
165
if ( this . options . enableReadyCheck ) {
165
166
this . _readyCheck ( function ( err , fail ) {
166
167
if ( err || fail ) {
167
- debug ( 'Ready check failed (%s). Reconnecting...' , err || fail )
168
+ debug ( 'Ready check failed (%s). Reconnecting...' , err || fail ) ;
168
169
if ( this . status === 'connect' ) {
169
170
this . disconnect ( true ) ;
170
171
}
@@ -175,7 +176,6 @@ Cluster.prototype.connect = function () {
175
176
} else {
176
177
readyHandler . call ( this ) ;
177
178
}
178
- resolve ( ) ;
179
179
} ;
180
180
181
181
closeListener = function ( ) {
@@ -276,7 +276,7 @@ Cluster.prototype.quit = function (callback) {
276
276
277
277
var Promise = PromiseContainer . get ( ) ;
278
278
if ( status === 'wait' ) {
279
- var ret = asCallback ( Promise . resolve ( 'OK' ) , callback )
279
+ var ret = asCallback ( Promise . resolve ( 'OK' ) , callback ) ;
280
280
281
281
// use setImmediate to make sure "close" event
282
282
// being emitted after quit() is returned
@@ -530,9 +530,9 @@ Cluster.prototype.sendCommand = function (command, stream, node) {
530
530
if ( typeof to === 'function' ) {
531
531
var nodes =
532
532
nodeKeys
533
- . map ( function ( key ) {
534
- return _this . connectionPool . nodes . all [ key ] ;
535
- } ) ;
533
+ . map ( function ( key ) {
534
+ return _this . connectionPool . nodes . all [ key ] ;
535
+ } ) ;
536
536
redis = to ( nodes , command ) ;
537
537
if ( Array . isArray ( redis ) ) {
538
538
redis = utils . sample ( redis ) ;
@@ -603,7 +603,11 @@ Cluster.prototype.handleError = function (error, ttl, handlers) {
603
603
timeout : this . options . retryDelayOnClusterDown ,
604
604
callback : this . refreshSlotsCache . bind ( this )
605
605
} ) ;
606
- } else if ( error . message === utils . CONNECTION_CLOSED_ERROR_MSG && this . options . retryDelayOnFailover > 0 && this . status === 'ready' ) {
606
+ } else if (
607
+ error . message === utils . CONNECTION_CLOSED_ERROR_MSG &&
608
+ this . options . retryDelayOnFailover > 0 &&
609
+ this . status === 'ready'
610
+ ) {
607
611
this . delayQueue . push ( 'failover' , handlers . connectionClosed , {
608
612
timeout : this . options . retryDelayOnFailover ,
609
613
callback : this . refreshSlotsCache . bind ( this )
@@ -683,16 +687,16 @@ Cluster.prototype._readyCheck = function (callback) {
683
687
} ;
684
688
685
689
[ 'sscan' , 'hscan' , 'zscan' , 'sscanBuffer' , 'hscanBuffer' , 'zscanBuffer' ]
686
- . forEach ( function ( command ) {
687
- Cluster . prototype [ command + 'Stream' ] = function ( key , options ) {
688
- return new ScanStream ( _ . defaults ( {
689
- objectMode : true ,
690
- key : key ,
691
- redis : this ,
692
- command : command
693
- } , options ) ) ;
694
- } ;
695
- } ) ;
690
+ . forEach ( function ( command ) {
691
+ Cluster . prototype [ command + 'Stream' ] = function ( key , options ) {
692
+ return new ScanStream ( _ . defaults ( {
693
+ objectMode : true ,
694
+ key : key ,
695
+ redis : this ,
696
+ command : command
697
+ } , options ) ) ;
698
+ } ;
699
+ } ) ;
696
700
697
701
require ( '../transaction' ) . addTransactionSupport ( Cluster . prototype ) ;
698
702
0 commit comments