File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -900,7 +900,7 @@ export class RedisAdapter extends Adapter {
900900 this . pubClient . constructor . name === "Cluster" ||
901901 this . pubClient . isCluster
902902 ) {
903- // Cluster
903+ // ioredis cluster
904904 const nodes = this . pubClient . nodes ( ) ;
905905 return Promise . all (
906906 nodes . map ( ( node ) =>
@@ -914,11 +914,32 @@ export class RedisAdapter extends Adapter {
914914 return numSub ;
915915 } ) ;
916916 } else if ( typeof this . pubClient . pSubscribe === "function" ) {
917- return this . pubClient
918- . sendCommand ( [ "pubsub" , "numsub" , this . requestChannel ] )
919- . then ( ( res ) => parseInt ( res [ 1 ] , 10 ) ) ;
917+ // node-redis client
918+ const isCluster = Array . isArray ( this . pubClient . masters ) ;
919+ if ( isCluster ) {
920+ const nodes = this . pubClient . masters ;
921+ return Promise . all (
922+ nodes . map ( ( node ) => {
923+ return node . client . sendCommand ( [
924+ "pubsub" ,
925+ "numsub" ,
926+ this . requestChannel ,
927+ ] ) ;
928+ } )
929+ ) . then ( ( values ) => {
930+ let numSub = 0 ;
931+ values . map ( ( value ) => {
932+ numSub += parseInt ( value [ 1 ] , 10 ) ;
933+ } ) ;
934+ return numSub ;
935+ } ) ;
936+ } else {
937+ return this . pubClient
938+ . sendCommand ( [ "pubsub" , "numsub" , this . requestChannel ] )
939+ . then ( ( res ) => parseInt ( res [ 1 ] , 10 ) ) ;
940+ }
920941 } else {
921- // RedisClient or Redis
942+ // ioredis or node-redis v3 client
922943 return new Promise ( ( resolve , reject ) => {
923944 this . pubClient . send_command (
924945 "pubsub" ,
You can’t perform that action at this time.
0 commit comments