@midwayjs/redis 3.19.0 → 4.0.0-alpha.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.
@@ -34,7 +34,8 @@ let RedisConfiguration = class RedisConfiguration {
34
34
  };
35
35
  }
36
36
  };
37
- RedisConfiguration = __decorate([
37
+ exports.RedisConfiguration = RedisConfiguration;
38
+ exports.RedisConfiguration = RedisConfiguration = __decorate([
38
39
  (0, core_1.Configuration)({
39
40
  namespace: 'redis',
40
41
  importConfigs: [
@@ -46,5 +47,4 @@ RedisConfiguration = __decorate([
46
47
  ],
47
48
  })
48
49
  ], RedisConfiguration);
49
- exports.RedisConfiguration = RedisConfiguration;
50
50
  //# sourceMappingURL=configuration.js.map
package/dist/manager.js CHANGED
@@ -20,28 +20,28 @@ let RedisServiceFactory = class RedisServiceFactory extends core_1.ServiceFactor
20
20
  async createClient(config) {
21
21
  let client;
22
22
  if (config.cluster === true) {
23
- assert(config.nodes && config.nodes.length !== 0, '[midway:redis] cluster nodes configuration is required when use cluster redis');
23
+ assert.ok(config.nodes && config.nodes.length !== 0, '[midway:redis] cluster nodes configuration is required when use cluster redis');
24
24
  config.nodes.forEach(client => {
25
- assert(client.host && client.port, `[midway:redis] 'host: ${client.host}', 'port: ${client.port}' are required on config`);
25
+ assert.ok(client.host && client.port, `[midway:redis] 'host: ${client.host}', 'port: ${client.port}' are required on config`);
26
26
  });
27
- this.logger.info('[midway:redis] cluster connecting');
28
27
  client = new ioredis_1.default.Cluster(config.nodes, config);
28
+ this.logger.info('[midway:redis] cluster is connecting');
29
29
  }
30
30
  else if (config.sentinels) {
31
- assert(config.sentinels && config.sentinels.length !== 0, '[midway:redis] sentinels configuration is required when use redis sentinel');
31
+ assert.ok(config.sentinels && config.sentinels.length !== 0, '[midway:redis] sentinels configuration is required when use redis sentinel');
32
32
  config.sentinels.forEach(sentinel => {
33
- assert(sentinel.host && sentinel.port, `[midway:redis] 'host: ${sentinel.host}', 'port: ${sentinel.port}' are required on config`);
33
+ assert.ok(sentinel.host && sentinel.port, `[midway:redis] 'host: ${sentinel.host}', 'port: ${sentinel.port}' are required on config`);
34
34
  });
35
- this.logger.info('[midway:redis] sentinel connecting start');
36
35
  client = new ioredis_1.default(config);
36
+ this.logger.info('[midway:redis] sentinel is connecting');
37
37
  }
38
38
  else {
39
- assert(config.host && config.port, `[midway:redis] 'host: ${config.host}', 'port: ${config.port}' are required on config`);
40
- this.logger.info('[midway:redis] server connecting redis://:***@%s:%s', config.host, config.port);
39
+ assert.ok(config.host && config.port, `[midway:redis] 'host: ${config.host}', 'port: ${config.port}' are required on config`);
41
40
  client = new ioredis_1.default(config);
41
+ this.logger.info('[midway:redis] server is connecting redis://:***@%s:%s', config.host, config.port);
42
42
  }
43
43
  await new Promise((resolve, reject) => {
44
- client.on('connect', () => {
44
+ client.on('ready', () => {
45
45
  this.logger.info('[midway:redis] client connect success');
46
46
  resolve();
47
47
  });
@@ -69,6 +69,7 @@ let RedisServiceFactory = class RedisServiceFactory extends core_1.ServiceFactor
69
69
  }
70
70
  }
71
71
  };
72
+ exports.RedisServiceFactory = RedisServiceFactory;
72
73
  __decorate([
73
74
  (0, core_1.Config)('redis'),
74
75
  __metadata("design:type", Object)
@@ -83,20 +84,19 @@ __decorate([
83
84
  (0, core_1.Logger)('coreLogger'),
84
85
  __metadata("design:type", Object)
85
86
  ], RedisServiceFactory.prototype, "logger", void 0);
86
- RedisServiceFactory = __decorate([
87
+ exports.RedisServiceFactory = RedisServiceFactory = __decorate([
87
88
  (0, core_1.Provide)(),
88
89
  (0, core_1.Scope)(core_1.ScopeEnum.Singleton)
89
90
  ], RedisServiceFactory);
90
- exports.RedisServiceFactory = RedisServiceFactory;
91
91
  let RedisService = class RedisService {
92
92
  async init() {
93
- var _a, _b;
94
- this.instance = this.serviceFactory.get(((_b = (_a = this.serviceFactory).getDefaultClientName) === null || _b === void 0 ? void 0 : _b.call(_a)) || 'default');
93
+ this.instance = this.serviceFactory.get(this.serviceFactory.getDefaultClientName?.() || 'default');
95
94
  if (!this.instance) {
96
95
  throw new core_1.MidwayCommonError('redis default instance not found.');
97
96
  }
98
97
  }
99
98
  };
99
+ exports.RedisService = RedisService;
100
100
  __decorate([
101
101
  (0, core_1.Inject)(),
102
102
  __metadata("design:type", RedisServiceFactory)
@@ -107,11 +107,10 @@ __decorate([
107
107
  __metadata("design:paramtypes", []),
108
108
  __metadata("design:returntype", Promise)
109
109
  ], RedisService.prototype, "init", null);
110
- RedisService = __decorate([
110
+ exports.RedisService = RedisService = __decorate([
111
111
  (0, core_1.Provide)(),
112
112
  (0, core_1.Scope)(core_1.ScopeEnum.Singleton)
113
113
  ], RedisService);
114
- exports.RedisService = RedisService;
115
114
  (0, core_1.delegateTargetAllPrototypeMethod)(RedisService, ioredis_1.default);
116
115
  RedisService.prototype.defineCommand = function (name, definition) {
117
116
  this.instance.defineCommand(name, definition);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@midwayjs/redis",
3
3
  "description": "midway redis component",
4
- "version": "3.19.0",
4
+ "version": "4.0.0-alpha.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": "^3.19.0",
14
- "@midwayjs/mock": "^3.19.0"
13
+ "@midwayjs/core": "^4.0.0-alpha.1",
14
+ "@midwayjs/mock": "^4.0.0-alpha.1"
15
15
  },
16
16
  "dependencies": {
17
17
  "ioredis": "5.4.1"
@@ -23,8 +23,8 @@
23
23
  "license": "MIT",
24
24
  "scripts": {
25
25
  "build": "tsc",
26
- "test": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand",
27
- "cov": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand --coverage --forceExit",
26
+ "test": "node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand",
27
+ "cov": "node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand --coverage --forceExit",
28
28
  "ci": "npm run test",
29
29
  "lint": "mwts check"
30
30
  },
@@ -35,5 +35,5 @@
35
35
  "type": "git",
36
36
  "url": "https://github.com/midwayjs/midway.git"
37
37
  },
38
- "gitHead": "437e92d9375b0e375f83aa363f3e6a60187c7109"
38
+ "gitHead": "14bb4da91805a1cf52f190c0d37a74b395dd6372"
39
39
  }