@midwayjs/etcd 4.0.0-beta.7 → 4.0.0-beta.9
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.
|
@@ -13,11 +13,14 @@ exports.EtcdServiceDiscovery = exports.EtcdServiceDiscoverClient = void 0;
|
|
|
13
13
|
const core_1 = require("@midwayjs/core");
|
|
14
14
|
const manager_1 = require("../manager");
|
|
15
15
|
class EtcdDataListener {
|
|
16
|
+
client;
|
|
17
|
+
serviceName;
|
|
18
|
+
data = [];
|
|
19
|
+
watcher;
|
|
20
|
+
destroyed = false;
|
|
16
21
|
constructor(client, serviceName) {
|
|
17
22
|
this.client = client;
|
|
18
23
|
this.serviceName = serviceName;
|
|
19
|
-
this.data = [];
|
|
20
|
-
this.destroyed = false;
|
|
21
24
|
}
|
|
22
25
|
async init() {
|
|
23
26
|
await this.refresh();
|
|
@@ -61,10 +64,15 @@ class EtcdDataListener {
|
|
|
61
64
|
}
|
|
62
65
|
}
|
|
63
66
|
class EtcdServiceDiscoverClient extends core_1.ServiceDiscoveryClient {
|
|
67
|
+
lease; // etcd3 的 Lease 实例
|
|
68
|
+
renewTimer;
|
|
69
|
+
ttl;
|
|
70
|
+
renewInterval;
|
|
71
|
+
logger;
|
|
72
|
+
registeredInstance = null;
|
|
73
|
+
onlineInstanceData = null;
|
|
64
74
|
constructor(client, serviceDiscoveryOptions, logger) {
|
|
65
75
|
super(client, serviceDiscoveryOptions);
|
|
66
|
-
this.registeredInstance = null;
|
|
67
|
-
this.onlineInstanceData = null;
|
|
68
76
|
this.ttl = serviceDiscoveryOptions.ttl || 30;
|
|
69
77
|
this.renewInterval = Math.floor(this.ttl / 3) * 1000;
|
|
70
78
|
this.logger = logger;
|
|
@@ -172,10 +180,11 @@ class EtcdServiceDiscoverClient extends core_1.ServiceDiscoveryClient {
|
|
|
172
180
|
}
|
|
173
181
|
exports.EtcdServiceDiscoverClient = EtcdServiceDiscoverClient;
|
|
174
182
|
let EtcdServiceDiscovery = class EtcdServiceDiscovery extends core_1.ServiceDiscovery {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
183
|
+
etcdServiceFactory;
|
|
184
|
+
configService;
|
|
185
|
+
etcdServiceDiscoveryOptions;
|
|
186
|
+
coreLogger;
|
|
187
|
+
listenerStore = new Map();
|
|
179
188
|
async init() {
|
|
180
189
|
this.etcdServiceDiscoveryOptions = this.configService.getConfiguration('etcd.serviceDiscovery', {});
|
|
181
190
|
}
|
package/dist/manager.js
CHANGED
|
@@ -13,11 +13,13 @@ exports.ETCDService = exports.ETCDServiceFactory = void 0;
|
|
|
13
13
|
const core_1 = require("@midwayjs/core");
|
|
14
14
|
const etcd3_1 = require("etcd3");
|
|
15
15
|
let ETCDServiceFactory = class ETCDServiceFactory extends core_1.ServiceFactory {
|
|
16
|
+
etcdConfig;
|
|
16
17
|
async init() {
|
|
17
18
|
await this.initClients(this.etcdConfig, {
|
|
18
19
|
concurrent: true,
|
|
19
20
|
});
|
|
20
21
|
}
|
|
22
|
+
logger;
|
|
21
23
|
async createClient(config) {
|
|
22
24
|
this.logger.info('[midway:etcd] init %s', config.hosts);
|
|
23
25
|
return new etcd3_1.Etcd3(config);
|
|
@@ -49,6 +51,8 @@ exports.ETCDServiceFactory = ETCDServiceFactory = __decorate([
|
|
|
49
51
|
(0, core_1.Scope)(core_1.ScopeEnum.Singleton)
|
|
50
52
|
], ETCDServiceFactory);
|
|
51
53
|
let ETCDService = class ETCDService {
|
|
54
|
+
serviceFactory;
|
|
55
|
+
instance;
|
|
52
56
|
async init() {
|
|
53
57
|
this.instance = this.serviceFactory.get(this.serviceFactory.getDefaultClientName?.() || 'default');
|
|
54
58
|
if (!this.instance) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/etcd",
|
|
3
3
|
"description": "midway etcd component",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.9",
|
|
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.0.0-beta.
|
|
14
|
-
"@midwayjs/mock": "^4.0.0-beta.
|
|
13
|
+
"@midwayjs/core": "^4.0.0-beta.9",
|
|
14
|
+
"@midwayjs/mock": "^4.0.0-beta.9"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"etcd3": "1.1.2"
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"type": "git",
|
|
37
37
|
"url": "https://github.com/midwayjs/midway.git"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "771e83974ef9f3d78c296e4ee0c8c68db44f6b31"
|
|
40
40
|
}
|