1+ import { v4 as uuidv4 } from 'uuid' ;
12import { Injectable , Logger , OnModuleInit } from '@nestjs/common' ;
23import { getAvailableEndpoints } from 'src/modules/autodiscovery/utils/autodiscovery.util' ;
34import { convertRedisInfoReplyToObject } from 'src/utils' ;
@@ -51,7 +52,7 @@ export class AutodiscoveryService implements OnModuleInit {
5152 return ;
5253 }
5354
54- await this . discoverDatabases ( ) ;
55+ await this . discoverDatabases ( sessionMetadata ) ;
5556 } catch ( e ) {
5657 this . logger . warn ( 'Unable to discover redis database' , e ) ;
5758 }
@@ -62,12 +63,12 @@ export class AutodiscoveryService implements OnModuleInit {
6263 * Database alias will be "host:port"
6364 * @private
6465 */
65- private async discoverDatabases ( ) {
66+ private async discoverDatabases ( sessionMetadata : SessionMetadata ) {
6667 const endpoints = await getAvailableEndpoints ( ) ;
6768
6869 // Add redis databases or resolve after 1s to not block app startup for a long time
6970 await Promise . race ( [
70- Promise . all ( endpoints . map ( this . addRedisDatabase . bind ( this ) ) ) ,
71+ Promise . all ( endpoints . map ( ( endpoint ) => this . addRedisDatabase ( sessionMetadata , endpoint ) ) ) ,
7172 new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) ) ,
7273 ] ) ;
7374 }
@@ -82,7 +83,9 @@ export class AutodiscoveryService implements OnModuleInit {
8283 try {
8384 const client = await this . redisClientFactory . createClient (
8485 {
86+ databaseId : uuidv4 ( ) ,
8587 context : ClientContext . Common ,
88+ sessionMetadata,
8689 } as ClientMetadata ,
8790 plainToClass ( Database , endpoint ) ,
8891 { useRetry : false , connectionName : 'redisinsight-auto-discovery' } ,
0 commit comments