@xnestjs/ioredis 1.6.2 → 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/get-redis-config.js +3 -1
- package/cjs/redis-core.module.js +19 -19
- package/esm/get-redis-config.js +3 -1
- package/esm/redis-core.module.js +19 -19
- package/package.json +1 -1
package/cjs/get-redis-config.js
CHANGED
|
@@ -38,6 +38,8 @@ function getRedisConfig(options, prefix = 'REDIS_') {
|
|
|
38
38
|
redisOptions.noDelay = redisOptions.noDelay ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'NO_DELAY']);
|
|
39
39
|
redisOptions.connectionName = redisOptions.connectionName ?? env[prefix + 'CONNECTION_NAME'];
|
|
40
40
|
redisOptions.maxRetriesPerRequest =
|
|
41
|
-
redisOptions.maxRetriesPerRequest
|
|
41
|
+
redisOptions.maxRetriesPerRequest === null
|
|
42
|
+
? null
|
|
43
|
+
: (redisOptions.maxRetriesPerRequest ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'MAX_RETRIES_PER_REQUEST']));
|
|
42
44
|
return out;
|
|
43
45
|
}
|
package/cjs/redis-core.module.js
CHANGED
|
@@ -124,25 +124,25 @@ let RedisCoreModule = RedisCoreModule_1 = class RedisCoreModule {
|
|
|
124
124
|
}
|
|
125
125
|
async onApplicationBootstrap() {
|
|
126
126
|
const opts = this.connectionOptions;
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
await this.client.redis.
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
127
|
+
if (opts.lazyConnect)
|
|
128
|
+
return;
|
|
129
|
+
const isCluster = (0, utils_js_1.isClusterOptions)(opts);
|
|
130
|
+
const hosts = isCluster
|
|
131
|
+
? opts.nodes
|
|
132
|
+
.map(x => (typeof x === 'object' ? x.host + ':' + x.port : typeof x === 'number' ? 'localhost:' + x : x))
|
|
133
|
+
.join(', ')
|
|
134
|
+
: opts.host;
|
|
135
|
+
if (hosts) {
|
|
136
|
+
this.logger?.log('Connecting to redis at ' + ansi_colors_1.default.blue(hosts));
|
|
137
|
+
common_1.Logger.flush();
|
|
138
|
+
try {
|
|
139
|
+
if (this.client.redis.status === 'wait')
|
|
140
|
+
await this.client.redis.connect();
|
|
141
|
+
await this.client.redis.ping();
|
|
142
|
+
}
|
|
143
|
+
catch (e) {
|
|
144
|
+
this.logger?.error('Redis connection failed: ' + e.message);
|
|
145
|
+
throw e;
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
}
|
package/esm/get-redis-config.js
CHANGED
|
@@ -34,6 +34,8 @@ export function getRedisConfig(options, prefix = 'REDIS_') {
|
|
|
34
34
|
redisOptions.noDelay = redisOptions.noDelay ?? toBoolean(env[prefix + 'NO_DELAY']);
|
|
35
35
|
redisOptions.connectionName = redisOptions.connectionName ?? env[prefix + 'CONNECTION_NAME'];
|
|
36
36
|
redisOptions.maxRetriesPerRequest =
|
|
37
|
-
redisOptions.maxRetriesPerRequest
|
|
37
|
+
redisOptions.maxRetriesPerRequest === null
|
|
38
|
+
? null
|
|
39
|
+
: (redisOptions.maxRetriesPerRequest ?? toInt(env[prefix + 'MAX_RETRIES_PER_REQUEST']));
|
|
38
40
|
return out;
|
|
39
41
|
}
|
package/esm/redis-core.module.js
CHANGED
|
@@ -121,25 +121,25 @@ let RedisCoreModule = RedisCoreModule_1 = class RedisCoreModule {
|
|
|
121
121
|
}
|
|
122
122
|
async onApplicationBootstrap() {
|
|
123
123
|
const opts = this.connectionOptions;
|
|
124
|
-
if (
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
await this.client.redis.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
124
|
+
if (opts.lazyConnect)
|
|
125
|
+
return;
|
|
126
|
+
const isCluster = isClusterOptions(opts);
|
|
127
|
+
const hosts = isCluster
|
|
128
|
+
? opts.nodes
|
|
129
|
+
.map(x => (typeof x === 'object' ? x.host + ':' + x.port : typeof x === 'number' ? 'localhost:' + x : x))
|
|
130
|
+
.join(', ')
|
|
131
|
+
: opts.host;
|
|
132
|
+
if (hosts) {
|
|
133
|
+
this.logger?.log('Connecting to redis at ' + colors.blue(hosts));
|
|
134
|
+
Logger.flush();
|
|
135
|
+
try {
|
|
136
|
+
if (this.client.redis.status === 'wait')
|
|
137
|
+
await this.client.redis.connect();
|
|
138
|
+
await this.client.redis.ping();
|
|
139
|
+
}
|
|
140
|
+
catch (e) {
|
|
141
|
+
this.logger?.error('Redis connection failed: ' + e.message);
|
|
142
|
+
throw e;
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
}
|