@@ -118,22 +118,37 @@ export function createRedisProviders(): Array<Provider<RedisService>> {
118118export const redisProviders : Provider [ ] = [
119119 {
120120 provide : REDIS_SUBSCRIBER_CLIENT ,
121- useFactory : ( ) : Redis => {
122- return new IORedis ( {
123- host : '127.0.0.1' ,
124- port : 6379 ,
125- // password: '', // uncomment if you need it
126- } ) ;
121+ useFactory : ( cfg : ConfigService ) : Redis => {
122+ const host = cfg . get ( 'QUEUE_REDIS_HOST' ) ;
123+ const port = cfg . get ( 'QUEUE_REDIS_PORT' ) ;
124+ const password = cfg . get ( 'QUEUE_REDIS_PASSWORD' ) ;
125+ const useTls = cfg . get ( 'QUEUE_REDIS_USE_TLS' ) ;
126+ const options : any = {
127+ host,
128+ port,
129+ ...( password ? { password } : { } ) ,
130+ ...( useTls ? { tls : { servername : host } } : { } ) ,
131+ } ;
132+ return new IORedis ( options ) ;
127133 } ,
134+ inject : [ ConfigService ] ,
128135 } ,
129136 {
130137 provide : REDIS_PUBLISHER_CLIENT ,
131- useFactory : ( ) : Redis => {
132- return new IORedis ( {
133- host : '127.0.0.1' ,
134- port : 6379 ,
135- } ) ;
138+ useFactory : ( cfg : ConfigService ) : Redis => {
139+ const host = cfg . get ( 'QUEUE_REDIS_HOST' ) ;
140+ const port = cfg . get ( 'QUEUE_REDIS_PORT' ) ;
141+ const password = cfg . get ( 'QUEUE_REDIS_PASSWORD' ) ;
142+ const useTls = cfg . get ( 'QUEUE_REDIS_USE_TLS' ) ;
143+ const options : any = {
144+ host,
145+ port,
146+ ...( password ? { password } : { } ) ,
147+ ...( useTls ? { tls : { servername : host } } : { } ) ,
148+ } ;
149+ return new IORedis ( options ) ;
136150 } ,
151+ inject : [ ConfigService ] ,
137152 } ,
138153 // Prefix-based providers are appended at module initialisation time:
139154 // ...createRedisProviders(),
0 commit comments