@midwayjs/redis 3.13.8 → 3.14.0
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/configuration.d.ts +5 -3
- package/dist/configuration.js +16 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/manager.d.ts +6 -6
- package/dist/manager.js +6 -1
- package/index.d.ts +0 -3
- package/package.json +4 -4
package/dist/configuration.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { HealthResult, ILifeCycle, IMidwayContainer } from '@midwayjs/core';
|
|
2
|
+
export declare class RedisConfiguration implements ILifeCycle {
|
|
3
|
+
onReady(container: IMidwayContainer): Promise<void>;
|
|
4
|
+
onStop(container: IMidwayContainer): Promise<void>;
|
|
5
|
+
onHealthCheck(container: IMidwayContainer): Promise<HealthResult>;
|
|
4
6
|
}
|
|
5
7
|
//# sourceMappingURL=configuration.d.ts.map
|
package/dist/configuration.js
CHANGED
|
@@ -17,6 +17,22 @@ let RedisConfiguration = class RedisConfiguration {
|
|
|
17
17
|
const factory = await container.getAsync(manager_1.RedisServiceFactory);
|
|
18
18
|
await factory.stop();
|
|
19
19
|
}
|
|
20
|
+
async onHealthCheck(container) {
|
|
21
|
+
const factory = await container.getAsync(manager_1.RedisServiceFactory);
|
|
22
|
+
const clients = factory.getClients();
|
|
23
|
+
// find status not ready
|
|
24
|
+
let clientName;
|
|
25
|
+
for (const [name, instance] of clients) {
|
|
26
|
+
if (instance.status !== 'ready' && !factory.isLowPriority(name)) {
|
|
27
|
+
clientName = name;
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
status: !clientName,
|
|
33
|
+
reason: clientName ? `redis client "${clientName}" is not ready` : '',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
20
36
|
};
|
|
21
37
|
RedisConfiguration = __decorate([
|
|
22
38
|
(0, core_1.Configuration)({
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -14,7 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Configuration = void 0;
|
|
17
|
+
exports.Redis = exports.Configuration = void 0;
|
|
18
|
+
const ioredis_1 = require("ioredis");
|
|
19
|
+
exports.Redis = ioredis_1.default;
|
|
18
20
|
var configuration_1 = require("./configuration");
|
|
19
21
|
Object.defineProperty(exports, "Configuration", { enumerable: true, get: function () { return configuration_1.RedisConfiguration; } });
|
|
20
22
|
__exportStar(require("./manager"), exports);
|
package/dist/manager.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ServiceFactory, ServiceFactoryConfigOption } from '@midwayjs/core';
|
|
1
|
+
import { ServiceFactory, ServiceFactoryConfigOption, ILogger } from '@midwayjs/core';
|
|
2
2
|
import Redis from 'ioredis';
|
|
3
3
|
import { RedisConfigOptions } from './interface';
|
|
4
4
|
export declare class RedisServiceFactory extends ServiceFactory<Redis> {
|
|
5
|
-
redisConfig: ServiceFactoryConfigOption<RedisConfigOptions>;
|
|
6
|
-
init(): Promise<void>;
|
|
7
|
-
logger:
|
|
8
|
-
createClient(config: any): Promise<Redis>;
|
|
5
|
+
protected redisConfig: ServiceFactoryConfigOption<RedisConfigOptions>;
|
|
6
|
+
protected init(): Promise<void>;
|
|
7
|
+
protected logger: ILogger;
|
|
8
|
+
protected createClient(config: any): Promise<Redis>;
|
|
9
9
|
getName(): string;
|
|
10
|
-
destroyClient(redisInstance: any): Promise<void>;
|
|
10
|
+
protected destroyClient(redisInstance: any): Promise<void>;
|
|
11
11
|
}
|
|
12
12
|
export declare class RedisService implements Redis {
|
|
13
13
|
private serviceFactory;
|
package/dist/manager.js
CHANGED
|
@@ -57,7 +57,12 @@ let RedisServiceFactory = class RedisServiceFactory extends core_1.ServiceFactor
|
|
|
57
57
|
}
|
|
58
58
|
async destroyClient(redisInstance) {
|
|
59
59
|
try {
|
|
60
|
-
|
|
60
|
+
if (redisInstance) {
|
|
61
|
+
const canQuit = !['end', 'close'].includes(redisInstance.status);
|
|
62
|
+
if (canQuit) {
|
|
63
|
+
await redisInstance.quit();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
61
66
|
}
|
|
62
67
|
catch (error) {
|
|
63
68
|
this.logger.error('[midway:redis] Redis quit failed.', error);
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/redis",
|
|
3
3
|
"description": "midway redis component",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.14.0",
|
|
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.
|
|
14
|
-
"@midwayjs/mock": "^3.
|
|
13
|
+
"@midwayjs/core": "^3.14.0",
|
|
14
|
+
"@midwayjs/mock": "^3.14.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"ioredis": "5.3.2"
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"type": "git",
|
|
36
36
|
"url": "https://github.com/midwayjs/midway.git"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "67e3a3596ffdb65a413064d30c68f1f7965af282"
|
|
39
39
|
}
|