@midwayjs/redis 4.0.3 → 4.2.1
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/dist/manager.js +24 -18
- package/package.json +4 -4
package/dist/manager.js
CHANGED
|
@@ -27,26 +27,32 @@ let RedisServiceFactory = class RedisServiceFactory extends core_1.ServiceFactor
|
|
|
27
27
|
traceInjector;
|
|
28
28
|
async createClient(config, name) {
|
|
29
29
|
let client;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
assert.ok(client.host && client.port, `[midway:redis] client(${name}) 'host: ${client.host}', 'port: ${client.port}' are required on config`);
|
|
34
|
-
});
|
|
35
|
-
client = new ioredis_1.default.Cluster(config.nodes, config);
|
|
36
|
-
this.logger.info('[midway:redis] cluster is connecting');
|
|
37
|
-
}
|
|
38
|
-
else if (config.sentinels) {
|
|
39
|
-
assert.ok(config.sentinels && config.sentinels.length !== 0, `[midway:redis] client(${name}) sentinels configuration is required when use redis sentinel`);
|
|
40
|
-
config.sentinels.forEach(sentinel => {
|
|
41
|
-
assert.ok(sentinel.host && sentinel.port, `[midway:redis] client(${name}) 'host: ${sentinel.host}', 'port: ${sentinel.port}' are required on config`);
|
|
42
|
-
});
|
|
43
|
-
client = new ioredis_1.default(config);
|
|
44
|
-
this.logger.info(`[midway:redis] client(${name}) sentinel is connecting`);
|
|
30
|
+
const { customClientClass, ...otherConfig } = config;
|
|
31
|
+
if (customClientClass) {
|
|
32
|
+
client = new customClientClass(otherConfig);
|
|
45
33
|
}
|
|
46
34
|
else {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
35
|
+
if (config.cluster === true) {
|
|
36
|
+
assert.ok(config.nodes && config.nodes.length !== 0, `[midway:redis] client(${name}) cluster nodes configuration is required when use cluster redis`);
|
|
37
|
+
config.nodes.forEach(client => {
|
|
38
|
+
assert.ok(client.host && client.port, `[midway:redis] client(${name}) 'host: ${client.host}', 'port: ${client.port}' are required on config`);
|
|
39
|
+
});
|
|
40
|
+
client = new ioredis_1.default.Cluster(config.nodes, config);
|
|
41
|
+
this.logger.info('[midway:redis] cluster is connecting');
|
|
42
|
+
}
|
|
43
|
+
else if (config.sentinels) {
|
|
44
|
+
assert.ok(config.sentinels && config.sentinels.length !== 0, `[midway:redis] client(${name}) sentinels configuration is required when use redis sentinel`);
|
|
45
|
+
config.sentinels.forEach(sentinel => {
|
|
46
|
+
assert.ok(sentinel.host && sentinel.port, `[midway:redis] client(${name}) 'host: ${sentinel.host}', 'port: ${sentinel.port}' are required on config`);
|
|
47
|
+
});
|
|
48
|
+
client = new ioredis_1.default(config);
|
|
49
|
+
this.logger.info(`[midway:redis] client(${name}) sentinel is connecting`);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
assert.ok(config.host && config.port, `[midway:redis] client(${name}) 'host: ${config.host}', 'port: ${config.port}' are required on config`);
|
|
53
|
+
client = new ioredis_1.default(config);
|
|
54
|
+
this.logger.info(`[midway:redis] client(${name}) server is connecting redis://:***@${config.host}:${config.port}`);
|
|
55
|
+
}
|
|
50
56
|
}
|
|
51
57
|
await new Promise((resolve, reject) => {
|
|
52
58
|
client.on('ready', () => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/redis",
|
|
3
3
|
"description": "midway redis component",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.2.1",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"index.d.ts"
|
|
11
11
|
],
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@midwayjs/core": "^4.
|
|
14
|
-
"@midwayjs/mock": "^4.
|
|
13
|
+
"@midwayjs/core": "^4.2.1",
|
|
14
|
+
"@midwayjs/mock": "^4.2.1"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"ioredis": "5.4.2"
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"type": "git",
|
|
36
36
|
"url": "https://github.com/midwayjs/midway.git"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "1b471cc7aa0ea4ec0182c678a2d4321d4eb8dcbf"
|
|
39
39
|
}
|