1
1
import {
2
2
HttpException , Injectable , Logger ,
3
3
} from '@nestjs/common' ;
4
+ import { v4 as uuidv4 } from 'uuid' ;
4
5
import { CreateSentinelDatabaseResponse } from 'src/modules/redis-sentinel/dto/create.sentinel.database.response' ;
5
6
import { CreateSentinelDatabasesDto } from 'src/modules/redis-sentinel/dto/create.sentinel.databases.dto' ;
6
7
import { Database } from 'src/modules/database/models/database' ;
@@ -12,6 +13,7 @@ import { RedisSentinelAnalytics } from 'src/modules/redis-sentinel/redis-sentine
12
13
import { DatabaseFactory } from 'src/modules/database/providers/database.factory' ;
13
14
import { discoverSentinelMasterGroups } from 'src/modules/redis/utils' ;
14
15
import { RedisClientFactory } from 'src/modules/redis/redis.client.factory' ;
16
+ import { ConstantsProvider } from 'src/modules/constants/providers/constants.provider' ;
15
17
16
18
@Injectable ( )
17
19
export class RedisSentinelService {
@@ -22,6 +24,7 @@ export class RedisSentinelService {
22
24
private readonly databaseService : DatabaseService ,
23
25
private readonly databaseFactory : DatabaseFactory ,
24
26
private readonly redisSentinelAnalytics : RedisSentinelAnalytics ,
27
+ private readonly constantsProvider : ConstantsProvider ,
25
28
) { }
26
29
27
30
/**
@@ -118,8 +121,8 @@ export class RedisSentinelService {
118
121
try {
119
122
const database = await this . databaseFactory . createStandaloneDatabaseModel ( dto ) ;
120
123
const client = await this . redisClientFactory . getConnectionStrategy ( ) . createStandaloneClient ( {
121
- sessionMetadata : { } as SessionMetadata ,
122
- databaseId : database . id ,
124
+ sessionMetadata : this . constantsProvider . getSystemSessionMetadata ( ) ,
125
+ databaseId : database . id || uuidv4 ( ) ,
123
126
context : ClientContext . Common ,
124
127
} , database , { useRetry : false } ) ;
125
128
result = await discoverSentinelMasterGroups ( client ) ;
0 commit comments