@hile/micro 3.0.3 → 3.0.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/dist/application.js +9 -6
- package/package.json +11 -12
package/dist/application.js
CHANGED
|
@@ -124,6 +124,15 @@ export class Application extends Server {
|
|
|
124
124
|
this._registryLookupTimeoutMs = registryLookupTimeoutMs;
|
|
125
125
|
this._requestTimeoutMs = requestTimeoutMs;
|
|
126
126
|
this._circuitBreaker = resolveCircuitBreakerOptions(circuitBreaker);
|
|
127
|
+
this.events.on('disconnect', (client) => {
|
|
128
|
+
const disconnectedKey = `${client.host}:${client.port}`;
|
|
129
|
+
// 一个物理连接可承载多个 namespace;集中清理可避免每次服务发现都向 Client 重复注册监听器。
|
|
130
|
+
for (const [namespace, stack] of this.namespaces) {
|
|
131
|
+
if (`${stack.host}:${stack.port}` !== disconnectedKey)
|
|
132
|
+
continue;
|
|
133
|
+
this.namespaces.delete(namespace);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
127
136
|
this.register('/-/health', async () => ({
|
|
128
137
|
status: 'ok',
|
|
129
138
|
registry: !!this.registry,
|
|
@@ -711,12 +720,6 @@ export class Application extends Server {
|
|
|
711
720
|
}
|
|
712
721
|
return client;
|
|
713
722
|
});
|
|
714
|
-
}).then(client => {
|
|
715
|
-
client.events.on('disconnect', () => {
|
|
716
|
-
if (this.namespaces.has(namespace)) {
|
|
717
|
-
this.namespaces.delete(namespace);
|
|
718
|
-
}
|
|
719
|
-
});
|
|
720
723
|
}).catch(e => {
|
|
721
724
|
// Registry unavailable but previously cached client still valid -> degrade
|
|
722
725
|
const cachedKey = `${cachedHost}:${cachedPort}`;
|
package/package.json
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hile/micro",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"build": "tsc -b && fix-esm-import-path --preserve-import-type ./dist",
|
|
8
|
-
"dev": "tsc -b --watch",
|
|
9
|
-
"test": "vitest run"
|
|
10
|
-
},
|
|
11
6
|
"files": [
|
|
12
7
|
"dist",
|
|
13
8
|
"README.md",
|
|
@@ -23,13 +18,17 @@
|
|
|
23
18
|
"vitest": "^4.0.18"
|
|
24
19
|
},
|
|
25
20
|
"dependencies": {
|
|
21
|
+
"internal-ip": "^9.0.0",
|
|
22
|
+
"ws": "^8.21.0",
|
|
23
|
+
"yaml": "^2.9.0",
|
|
26
24
|
"@hile/context": "^3.0.2",
|
|
27
25
|
"@hile/logger": "^3.0.0",
|
|
28
26
|
"@hile/message-loader": "^3.0.0",
|
|
29
|
-
"@hile/message-ws": "^3.0.0"
|
|
30
|
-
"internal-ip": "^9.0.0",
|
|
31
|
-
"ws": "^8.21.0",
|
|
32
|
-
"yaml": "^2.9.0"
|
|
27
|
+
"@hile/message-ws": "^3.0.0"
|
|
33
28
|
},
|
|
34
|
-
"
|
|
35
|
-
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc -b && fix-esm-import-path --preserve-import-type ./dist",
|
|
31
|
+
"dev": "tsc -b --watch",
|
|
32
|
+
"test": "vitest run"
|
|
33
|
+
}
|
|
34
|
+
}
|