@midwayjs/mongoose 3.13.9 → 3.14.3
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 +2 -1
- package/dist/configuration.js +18 -0
- package/package.json +5 -5
package/dist/configuration.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ILifeCycle, IMidwayContainer } from '@midwayjs/core';
|
|
1
|
+
import { HealthResult, ILifeCycle, IMidwayContainer } from '@midwayjs/core';
|
|
2
2
|
import { MongooseDataSourceManager } from './manager';
|
|
3
3
|
export declare class MongooseConfiguration implements ILifeCycle {
|
|
4
4
|
mongooseDataSourceManager: MongooseDataSourceManager;
|
|
5
5
|
onReady(container: IMidwayContainer): Promise<void>;
|
|
6
6
|
onStop(container: IMidwayContainer): Promise<void>;
|
|
7
|
+
onHealthCheck?(container: IMidwayContainer): Promise<HealthResult>;
|
|
7
8
|
}
|
|
8
9
|
//# sourceMappingURL=configuration.d.ts.map
|
package/dist/configuration.js
CHANGED
|
@@ -16,6 +16,24 @@ let MongooseConfiguration = class MongooseConfiguration {
|
|
|
16
16
|
async onStop(container) {
|
|
17
17
|
await this.mongooseDataSourceManager.stop();
|
|
18
18
|
}
|
|
19
|
+
async onHealthCheck(container) {
|
|
20
|
+
const clientNames = this.mongooseDataSourceManager.getDataSourceNames();
|
|
21
|
+
// find status not ready
|
|
22
|
+
let clientName;
|
|
23
|
+
for (const name of clientNames) {
|
|
24
|
+
if ((await this.mongooseDataSourceManager.isConnected(name)) &&
|
|
25
|
+
!this.mongooseDataSourceManager.isLowPriority(name)) {
|
|
26
|
+
clientName = name;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
status: !clientName,
|
|
32
|
+
reason: clientName
|
|
33
|
+
? `mongoose dataSource "${clientName}" is not ready`
|
|
34
|
+
: '',
|
|
35
|
+
};
|
|
36
|
+
}
|
|
19
37
|
};
|
|
20
38
|
MongooseConfiguration = __decorate([
|
|
21
39
|
(0, core_1.Configuration)({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/mongoose",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.14.3",
|
|
4
4
|
"description": "Midway Component for mongoose",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
},
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@midwayjs/core": "^3.
|
|
26
|
-
"@midwayjs/mock": "^3.
|
|
27
|
-
"mongoose": "7.6.
|
|
25
|
+
"@midwayjs/core": "^3.14.3",
|
|
26
|
+
"@midwayjs/mock": "^3.14.3",
|
|
27
|
+
"mongoose": "7.6.8"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "7517e708722bbf9ba69d9406e73fa2597e485d24"
|
|
30
30
|
}
|