@@ -188,7 +188,7 @@ export default class RedisCluster<
188
188
const parser = new BasicCommandParser ( ) ;
189
189
command . parseCommand ( parser , ...args ) ;
190
190
191
- return this . _self . #execute (
191
+ return this . _self . _execute (
192
192
parser . firstKey ,
193
193
command . IS_READ_ONLY ,
194
194
this . _commandOptions ,
@@ -204,7 +204,7 @@ export default class RedisCluster<
204
204
const parser = new BasicCommandParser ( ) ;
205
205
command . parseCommand ( parser , ...args ) ;
206
206
207
- return this . _self . #execute (
207
+ return this . _self . _execute (
208
208
parser . firstKey ,
209
209
command . IS_READ_ONLY ,
210
210
this . _self . _commandOptions ,
@@ -222,7 +222,7 @@ export default class RedisCluster<
222
222
parser . push ( ...prefix ) ;
223
223
fn . parseCommand ( parser , ...args ) ;
224
224
225
- return this . _self . #execute (
225
+ return this . _self . _execute (
226
226
parser . firstKey ,
227
227
fn . IS_READ_ONLY ,
228
228
this . _self . _commandOptions ,
@@ -240,7 +240,7 @@ export default class RedisCluster<
240
240
parser . push ( ...prefix ) ;
241
241
script . parseCommand ( parser , ...args ) ;
242
242
243
- return this . _self . #execute (
243
+ return this . _self . _execute (
244
244
parser . firstKey ,
245
245
script . IS_READ_ONLY ,
246
246
this . _commandOptions ,
@@ -293,9 +293,9 @@ export default class RedisCluster<
293
293
return RedisCluster . factory ( options ) ( options ) ;
294
294
}
295
295
296
- readonly #options : RedisClusterOptions < M , F , S , RESP , TYPE_MAPPING /*, POLICIES*/ > ;
296
+ readonly _options : RedisClusterOptions < M , F , S , RESP , TYPE_MAPPING /*, POLICIES*/ > ;
297
297
298
- readonly #slots : RedisClusterSlots < M , F , S , RESP , TYPE_MAPPING > ;
298
+ readonly _slots : RedisClusterSlots < M , F , S , RESP , TYPE_MAPPING > ;
299
299
300
300
private _self = this ;
301
301
private _commandOptions ?: ClusterCommandOptions < TYPE_MAPPING /*, POLICIES*/ > ;
@@ -305,53 +305,53 @@ export default class RedisCluster<
305
305
* Use with {@link RedisCluster.prototype.nodeClient} to get the client for a specific node (master or replica).
306
306
*/
307
307
get slots ( ) {
308
- return this . _self . #slots . slots ;
308
+ return this . _self . _slots . slots ;
309
309
}
310
310
311
311
get clientSideCache ( ) {
312
- return this . _self . #slots . clientSideCache ;
312
+ return this . _self . _slots . clientSideCache ;
313
313
}
314
314
315
315
/**
316
316
* An array of the cluster masters.
317
317
* Use with {@link RedisCluster.prototype.nodeClient} to get the client for a specific master node.
318
318
*/
319
319
get masters ( ) {
320
- return this . _self . #slots . masters ;
320
+ return this . _self . _slots . masters ;
321
321
}
322
322
323
323
/**
324
324
* An array of the cluster replicas.
325
325
* Use with {@link RedisCluster.prototype.nodeClient} to get the client for a specific replica node.
326
326
*/
327
327
get replicas ( ) {
328
- return this . _self . #slots . replicas ;
328
+ return this . _self . _slots . replicas ;
329
329
}
330
330
331
331
/**
332
332
* A map form a node address (`<host>:<port>`) to its shard, each shard contain its `master` and `replicas`.
333
333
* Use with {@link RedisCluster.prototype.nodeClient} to get the client for a specific node (master or replica).
334
334
*/
335
335
get nodeByAddress ( ) {
336
- return this . _self . #slots . nodeByAddress ;
336
+ return this . _self . _slots . nodeByAddress ;
337
337
}
338
338
339
339
/**
340
340
* The current pub/sub node.
341
341
*/
342
342
get pubSubNode ( ) {
343
- return this . _self . #slots . pubSubNode ;
343
+ return this . _self . _slots . pubSubNode ;
344
344
}
345
345
346
346
get isOpen ( ) {
347
- return this . _self . #slots . isOpen ;
347
+ return this . _self . _slots . isOpen ;
348
348
}
349
349
350
350
constructor ( options : RedisClusterOptions < M , F , S , RESP , TYPE_MAPPING /*, POLICIES*/ > ) {
351
351
super ( ) ;
352
352
353
- this . #options = options ;
354
- this . #slots = new RedisClusterSlots ( options , this . emit . bind ( this ) ) ;
353
+ this . _options = options ;
354
+ this . _slots = new RedisClusterSlots ( options , this . emit . bind ( this ) ) ;
355
355
356
356
if ( options ?. commandOptions ) {
357
357
this . _commandOptions = options . commandOptions ;
@@ -366,14 +366,14 @@ export default class RedisCluster<
366
366
_TYPE_MAPPING extends TypeMapping = TYPE_MAPPING
367
367
> ( overrides ?: Partial < RedisClusterOptions < _M , _F , _S , _RESP , _TYPE_MAPPING > > ) {
368
368
return new ( Object . getPrototypeOf ( this ) . constructor ) ( {
369
- ...this . _self . #options ,
369
+ ...this . _self . _options ,
370
370
commandOptions : this . _commandOptions ,
371
371
...overrides
372
372
} ) as RedisClusterType < _M , _F , _S , _RESP , _TYPE_MAPPING > ;
373
373
}
374
374
375
375
async connect ( ) {
376
- await this . _self . #slots . connect ( ) ;
376
+ await this . _self . _slots . connect ( ) ;
377
377
return this as unknown as RedisClusterType < M , F , S , RESP , TYPE_MAPPING > ;
378
378
}
379
379
@@ -429,7 +429,7 @@ export default class RedisCluster<
429
429
// return this._commandOptionsProxy('policies', policies);
430
430
// }
431
431
432
- #handleAsk < T > (
432
+ _handleAsk < T > (
433
433
fn : ( client : RedisClientType < M , F , S , RESP , TYPE_MAPPING > , opts ?: ClusterCommandOptions ) => Promise < T >
434
434
) {
435
435
return async ( client : RedisClientType < M , F , S , RESP , TYPE_MAPPING > , options ?: ClusterCommandOptions ) => {
@@ -450,14 +450,14 @@ export default class RedisCluster<
450
450
} ;
451
451
}
452
452
453
- async #execute < T > (
453
+ async _execute < T > (
454
454
firstKey : RedisArgument | undefined ,
455
455
isReadonly : boolean | undefined ,
456
456
options : ClusterCommandOptions | undefined ,
457
457
fn : ( client : RedisClientType < M , F , S , RESP , TYPE_MAPPING > , opts ?: ClusterCommandOptions ) => Promise < T >
458
458
) : Promise < T > {
459
- const maxCommandRedirections = this . #options . maxCommandRedirections ?? 16 ;
460
- let client = await this . #slots . getClient ( firstKey , isReadonly ) ;
459
+ const maxCommandRedirections = this . _options . maxCommandRedirections ?? 16 ;
460
+ let client = await this . _slots . getClient ( firstKey , isReadonly ) ;
461
461
let i = 0 ;
462
462
463
463
let myFn = fn ;
@@ -475,24 +475,24 @@ export default class RedisCluster<
475
475
476
476
if ( err . message . startsWith ( 'ASK' ) ) {
477
477
const address = err . message . substring ( err . message . lastIndexOf ( ' ' ) + 1 ) ;
478
- let redirectTo = await this . #slots . getMasterByAddress ( address ) ;
478
+ let redirectTo = await this . _slots . getMasterByAddress ( address ) ;
479
479
if ( ! redirectTo ) {
480
- await this . #slots . rediscover ( client ) ;
481
- redirectTo = await this . #slots . getMasterByAddress ( address ) ;
480
+ await this . _slots . rediscover ( client ) ;
481
+ redirectTo = await this . _slots . getMasterByAddress ( address ) ;
482
482
}
483
483
484
484
if ( ! redirectTo ) {
485
485
throw new Error ( `Cannot find node ${ address } ` ) ;
486
486
}
487
487
488
488
client = redirectTo ;
489
- myFn = this . #handleAsk ( fn ) ;
489
+ myFn = this . _handleAsk ( fn ) ;
490
490
continue ;
491
491
}
492
492
493
493
if ( err . message . startsWith ( 'MOVED' ) ) {
494
- await this . #slots . rediscover ( client ) ;
495
- client = await this . #slots . getClient ( firstKey , isReadonly ) ;
494
+ await this . _slots . rediscover ( client ) ;
495
+ client = await this . _slots . getClient ( firstKey , isReadonly ) ;
496
496
continue ;
497
497
}
498
498
@@ -508,7 +508,7 @@ export default class RedisCluster<
508
508
options ?: ClusterCommandOptions ,
509
509
// defaultPolicies?: CommandPolicies
510
510
) : Promise < T > {
511
- return this . _self . #execute (
511
+ return this . _self . _execute (
512
512
firstKey ,
513
513
isReadonly ,
514
514
options ,
@@ -520,11 +520,11 @@ export default class RedisCluster<
520
520
type Multi = new ( ...args : ConstructorParameters < typeof RedisClusterMultiCommand > ) => RedisClusterMultiCommandType < [ ] , M , F , S , RESP , TYPE_MAPPING > ;
521
521
return new ( ( this as any ) . Multi as Multi ) (
522
522
async ( firstKey , isReadonly , commands ) => {
523
- const client = await this . _self . #slots . getClient ( firstKey , isReadonly ) ;
523
+ const client = await this . _self . _slots . getClient ( firstKey , isReadonly ) ;
524
524
return client . _executeMulti ( commands ) ;
525
525
} ,
526
526
async ( firstKey , isReadonly , commands ) => {
527
- const client = await this . _self . #slots . getClient ( firstKey , isReadonly ) ;
527
+ const client = await this . _self . _slots . getClient ( firstKey , isReadonly ) ;
528
528
return client . _executePipeline ( commands ) ;
529
529
} ,
530
530
routing ,
@@ -539,7 +539,7 @@ export default class RedisCluster<
539
539
listener : PubSubListener < T > ,
540
540
bufferMode ?: T
541
541
) {
542
- return ( await this . _self . #slots . getPubSubClient ( ) )
542
+ return ( await this . _self . _slots . getPubSubClient ( ) )
543
543
. SUBSCRIBE ( channels , listener , bufferMode ) ;
544
544
}
545
545
@@ -550,7 +550,7 @@ export default class RedisCluster<
550
550
listener ?: PubSubListener < boolean > ,
551
551
bufferMode ?: T
552
552
) {
553
- return this . _self . #slots . executeUnsubscribeCommand ( client =>
553
+ return this . _self . _slots . executeUnsubscribeCommand ( client =>
554
554
client . UNSUBSCRIBE ( channels , listener , bufferMode )
555
555
) ;
556
556
}
@@ -562,7 +562,7 @@ export default class RedisCluster<
562
562
listener : PubSubListener < T > ,
563
563
bufferMode ?: T
564
564
) {
565
- return ( await this . _self . #slots . getPubSubClient ( ) )
565
+ return ( await this . _self . _slots . getPubSubClient ( ) )
566
566
. PSUBSCRIBE ( patterns , listener , bufferMode ) ;
567
567
}
568
568
@@ -573,7 +573,7 @@ export default class RedisCluster<
573
573
listener ?: PubSubListener < T > ,
574
574
bufferMode ?: T
575
575
) {
576
- return this . _self . #slots . executeUnsubscribeCommand ( client =>
576
+ return this . _self . _slots . executeUnsubscribeCommand ( client =>
577
577
client . PUNSUBSCRIBE ( patterns , listener , bufferMode )
578
578
) ;
579
579
}
@@ -585,9 +585,9 @@ export default class RedisCluster<
585
585
listener : PubSubListener < T > ,
586
586
bufferMode ?: T
587
587
) {
588
- const maxCommandRedirections = this . _self . #options . maxCommandRedirections ?? 16 ,
588
+ const maxCommandRedirections = this . _self . _options . maxCommandRedirections ?? 16 ,
589
589
firstChannel = Array . isArray ( channels ) ? channels [ 0 ] : channels ;
590
- let client = await this . _self . #slots . getShardedPubSubClient ( firstChannel ) ;
590
+ let client = await this . _self . _slots . getShardedPubSubClient ( firstChannel ) ;
591
591
for ( let i = 0 ; ; i ++ ) {
592
592
try {
593
593
return await client . SSUBSCRIBE ( channels , listener , bufferMode ) ;
@@ -597,8 +597,8 @@ export default class RedisCluster<
597
597
}
598
598
599
599
if ( err . message . startsWith ( 'MOVED' ) ) {
600
- await this . _self . #slots . rediscover ( client ) ;
601
- client = await this . _self . #slots . getShardedPubSubClient ( firstChannel ) ;
600
+ await this . _self . _slots . rediscover ( client ) ;
601
+ client = await this . _self . _slots . getShardedPubSubClient ( firstChannel ) ;
602
602
continue ;
603
603
}
604
604
@@ -614,7 +614,7 @@ export default class RedisCluster<
614
614
listener ?: PubSubListener < T > ,
615
615
bufferMode ?: T
616
616
) {
617
- return this . _self . #slots . executeShardedUnsubscribeCommand (
617
+ return this . _self . _slots . executeShardedUnsubscribeCommand (
618
618
Array . isArray ( channels ) ? channels [ 0 ] : channels ,
619
619
client => client . SUNSUBSCRIBE ( channels , listener , bufferMode )
620
620
) ;
@@ -626,44 +626,44 @@ export default class RedisCluster<
626
626
* @deprecated Use `close` instead.
627
627
*/
628
628
quit ( ) {
629
- return this . _self . #slots . quit ( ) ;
629
+ return this . _self . _slots . quit ( ) ;
630
630
}
631
631
632
632
/**
633
633
* @deprecated Use `destroy` instead.
634
634
*/
635
635
disconnect ( ) {
636
- return this . _self . #slots . disconnect ( ) ;
636
+ return this . _self . _slots . disconnect ( ) ;
637
637
}
638
638
639
639
close ( ) {
640
- this . _self . #slots . clientSideCache ?. onPoolClose ( ) ;
641
- return this . _self . #slots . close ( ) ;
640
+ this . _self . _slots . clientSideCache ?. onPoolClose ( ) ;
641
+ return this . _self . _slots . close ( ) ;
642
642
}
643
643
644
644
destroy ( ) {
645
- this . _self . #slots . clientSideCache ?. onPoolClose ( ) ;
646
- return this . _self . #slots . destroy ( ) ;
645
+ this . _self . _slots . clientSideCache ?. onPoolClose ( ) ;
646
+ return this . _self . _slots . destroy ( ) ;
647
647
}
648
648
649
649
nodeClient ( node : ShardNode < M , F , S , RESP , TYPE_MAPPING > ) {
650
- return this . _self . #slots . nodeClient ( node ) ;
650
+ return this . _self . _slots . nodeClient ( node ) ;
651
651
}
652
652
653
653
/**
654
654
* Returns a random node from the cluster.
655
655
* Userful for running "forward" commands (like PUBLISH) on a random node.
656
656
*/
657
657
getRandomNode ( ) {
658
- return this . _self . #slots . getRandomNode ( ) ;
658
+ return this . _self . _slots . getRandomNode ( ) ;
659
659
}
660
660
661
661
/**
662
662
* Get a random node from a slot.
663
663
* Useful for running readonly commands on a slot.
664
664
*/
665
665
getSlotRandomNode ( slot : number ) {
666
- return this . _self . #slots . getSlotRandomNode ( slot ) ;
666
+ return this . _self . _slots . getSlotRandomNode ( slot ) ;
667
667
}
668
668
669
669
/**
0 commit comments