@webex/webex-core 3.0.0-beta.2 → 3.0.0-beta.21
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/config.js +1 -11
- package/dist/config.js.map +1 -1
- package/dist/credentials-config.js +44 -64
- package/dist/credentials-config.js.map +1 -1
- package/dist/index.js +0 -76
- package/dist/index.js.map +1 -1
- package/dist/interceptors/auth.js +22 -55
- package/dist/interceptors/auth.js.map +1 -1
- package/dist/interceptors/default-options.js +0 -20
- package/dist/interceptors/default-options.js.map +1 -1
- package/dist/interceptors/embargo.js +0 -21
- package/dist/interceptors/embargo.js.map +1 -1
- package/dist/interceptors/network-timing.js +2 -21
- package/dist/interceptors/network-timing.js.map +1 -1
- package/dist/interceptors/payload-transformer.js +2 -22
- package/dist/interceptors/payload-transformer.js.map +1 -1
- package/dist/interceptors/rate-limit.js +25 -57
- package/dist/interceptors/rate-limit.js.map +1 -1
- package/dist/interceptors/redirect.js +4 -33
- package/dist/interceptors/redirect.js.map +1 -1
- package/dist/interceptors/request-event.js +3 -30
- package/dist/interceptors/request-event.js.map +1 -1
- package/dist/interceptors/request-logger.js +1 -30
- package/dist/interceptors/request-logger.js.map +1 -1
- package/dist/interceptors/request-timing.js +3 -22
- package/dist/interceptors/request-timing.js.map +1 -1
- package/dist/interceptors/response-logger.js +2 -31
- package/dist/interceptors/response-logger.js.map +1 -1
- package/dist/interceptors/user-agent.js +2 -29
- package/dist/interceptors/user-agent.js.map +1 -1
- package/dist/interceptors/webex-tracking-id.js +5 -28
- package/dist/interceptors/webex-tracking-id.js.map +1 -1
- package/dist/interceptors/webex-user-agent.js +5 -38
- package/dist/interceptors/webex-user-agent.js.map +1 -1
- package/dist/lib/batcher.js +3 -51
- package/dist/lib/batcher.js.map +1 -1
- package/dist/lib/credentials/credentials.js +39 -119
- package/dist/lib/credentials/credentials.js.map +1 -1
- package/dist/lib/credentials/grant-errors.js +0 -49
- package/dist/lib/credentials/grant-errors.js.map +1 -1
- package/dist/lib/credentials/index.js +1 -13
- package/dist/lib/credentials/index.js.map +1 -1
- package/dist/lib/credentials/scope.js +1 -7
- package/dist/lib/credentials/scope.js.map +1 -1
- package/dist/lib/credentials/token-collection.js +1 -7
- package/dist/lib/credentials/token-collection.js.map +1 -1
- package/dist/lib/credentials/token.js +39 -118
- package/dist/lib/credentials/token.js.map +1 -1
- package/dist/lib/page.js +13 -26
- package/dist/lib/page.js.map +1 -1
- package/dist/lib/services/constants.js +0 -2
- package/dist/lib/services/constants.js.map +1 -1
- package/dist/lib/services/index.js +1 -28
- package/dist/lib/services/index.js.map +1 -1
- package/dist/lib/services/interceptors/server-error.js +2 -23
- package/dist/lib/services/interceptors/server-error.js.map +1 -1
- package/dist/lib/services/interceptors/service.js +12 -34
- package/dist/lib/services/interceptors/service.js.map +1 -1
- package/dist/lib/services/metrics.js +0 -2
- package/dist/lib/services/metrics.js.map +1 -1
- package/dist/lib/services/service-catalog.js +10 -90
- package/dist/lib/services/service-catalog.js.map +1 -1
- package/dist/lib/services/service-fed-ramp.js +0 -2
- package/dist/lib/services/service-fed-ramp.js.map +1 -1
- package/dist/lib/services/service-host.js +47 -62
- package/dist/lib/services/service-host.js.map +1 -1
- package/dist/lib/services/service-registry.js +78 -90
- package/dist/lib/services/service-registry.js.map +1 -1
- package/dist/lib/services/service-state.js +3 -15
- package/dist/lib/services/service-state.js.map +1 -1
- package/dist/lib/services/service-url.js +4 -25
- package/dist/lib/services/service-url.js.map +1 -1
- package/dist/lib/services/services.js +122 -238
- package/dist/lib/services/services.js.map +1 -1
- package/dist/lib/stateless-webex-plugin.js +5 -28
- package/dist/lib/stateless-webex-plugin.js.map +1 -1
- package/dist/lib/storage/decorators.js +19 -62
- package/dist/lib/storage/decorators.js.map +1 -1
- package/dist/lib/storage/errors.js +0 -23
- package/dist/lib/storage/errors.js.map +1 -1
- package/dist/lib/storage/index.js +2 -16
- package/dist/lib/storage/index.js.map +1 -1
- package/dist/lib/storage/make-webex-plugin-store.js +11 -41
- package/dist/lib/storage/make-webex-plugin-store.js.map +1 -1
- package/dist/lib/storage/make-webex-store.js +8 -30
- package/dist/lib/storage/make-webex-store.js.map +1 -1
- package/dist/lib/storage/memory-store-adapter.js +1 -19
- package/dist/lib/storage/memory-store-adapter.js.map +1 -1
- package/dist/lib/webex-core-plugin-mixin.js +9 -29
- package/dist/lib/webex-core-plugin-mixin.js.map +1 -1
- package/dist/lib/webex-http-error.js +1 -31
- package/dist/lib/webex-http-error.js.map +1 -1
- package/dist/lib/webex-internal-core-plugin-mixin.js +9 -29
- package/dist/lib/webex-internal-core-plugin-mixin.js.map +1 -1
- package/dist/lib/webex-plugin.js +6 -40
- package/dist/lib/webex-plugin.js.map +1 -1
- package/dist/plugins/logger.js +3 -17
- package/dist/plugins/logger.js.map +1 -1
- package/dist/webex-core.js +79 -203
- package/dist/webex-core.js.map +1 -1
- package/dist/webex-internal-core.js +0 -10
- package/dist/webex-internal-core.js.map +1 -1
- package/package.json +14 -14
- package/src/config.js +9 -11
- package/src/credentials-config.js +110 -72
- package/src/index.js +4 -14
- package/src/interceptors/auth.js +36 -37
- package/src/interceptors/default-options.js +0 -1
- package/src/interceptors/embargo.js +1 -1
- package/src/interceptors/payload-transformer.js +1 -2
- package/src/interceptors/rate-limit.js +8 -5
- package/src/interceptors/redirect.js +14 -8
- package/src/interceptors/request-event.js +4 -8
- package/src/interceptors/request-logger.js +8 -5
- package/src/interceptors/response-logger.js +11 -8
- package/src/interceptors/user-agent.js +1 -2
- package/src/interceptors/webex-user-agent.js +3 -9
- package/src/lib/batcher.js +70 -69
- package/src/lib/credentials/credentials.js +112 -122
- package/src/lib/credentials/grant-errors.js +6 -7
- package/src/lib/credentials/index.js +1 -4
- package/src/lib/credentials/scope.js +1 -4
- package/src/lib/credentials/token-collection.js +1 -1
- package/src/lib/credentials/token.js +86 -80
- package/src/lib/page.js +10 -11
- package/src/lib/services/constants.js +3 -13
- package/src/lib/services/index.js +2 -2
- package/src/lib/services/interceptors/server-error.js +12 -7
- package/src/lib/services/interceptors/service.js +6 -5
- package/src/lib/services/metrics.js +1 -1
- package/src/lib/services/service-catalog.js +110 -100
- package/src/lib/services/service-fed-ramp.js +1 -2
- package/src/lib/services/service-host.js +10 -17
- package/src/lib/services/service-registry.js +69 -96
- package/src/lib/services/service-state.js +4 -6
- package/src/lib/services/service-url.js +24 -23
- package/src/lib/services/services.js +260 -251
- package/src/lib/stateless-webex-plugin.js +4 -2
- package/src/lib/storage/decorators.js +68 -66
- package/src/lib/storage/index.js +4 -6
- package/src/lib/storage/make-webex-plugin-store.js +34 -21
- package/src/lib/storage/make-webex-store.js +6 -7
- package/src/lib/storage/memory-store-adapter.js +3 -3
- package/src/lib/webex-core-plugin-mixin.js +10 -7
- package/src/lib/webex-http-error.js +7 -8
- package/src/lib/webex-internal-core-plugin-mixin.js +9 -6
- package/src/lib/webex-plugin.js +41 -34
- package/src/plugins/logger.js +8 -3
- package/src/webex-core.js +185 -116
- package/src/webex-internal-core.js +15 -9
- package/test/integration/spec/credentials/credentials.js +26 -30
- package/test/integration/spec/credentials/token.js +36 -33
- package/test/integration/spec/services/service-catalog.js +177 -156
- package/test/integration/spec/services/services.js +313 -304
- package/test/integration/spec/webex-core.js +98 -86
- package/test/unit/spec/_setup.js +26 -18
- package/test/unit/spec/credentials/credentials.js +189 -154
- package/test/unit/spec/credentials/token.js +94 -76
- package/test/unit/spec/interceptors/auth.js +291 -243
- package/test/unit/spec/interceptors/default-options.js +36 -24
- package/test/unit/spec/interceptors/embargo.js +32 -27
- package/test/unit/spec/interceptors/network-timing.js +2 -2
- package/test/unit/spec/interceptors/payload-transformer.js +61 -52
- package/test/unit/spec/interceptors/rate-limit.js +104 -75
- package/test/unit/spec/interceptors/redirect.js +22 -20
- package/test/unit/spec/interceptors/request-timing.js +18 -22
- package/test/unit/spec/interceptors/user-agent.js +28 -16
- package/test/unit/spec/interceptors/webex-tracking-id.js +14 -8
- package/test/unit/spec/interceptors/webex-user-agent.js +83 -37
- package/test/unit/spec/lib/batcher.js +36 -32
- package/test/unit/spec/lib/page.js +36 -32
- package/test/unit/spec/lib/webex-plugin.js +1 -1
- package/test/unit/spec/services/interceptors/server-error.js +67 -90
- package/test/unit/spec/services/interceptors/service.js +17 -28
- package/test/unit/spec/services/service-catalog.js +19 -27
- package/test/unit/spec/services/service-host.js +29 -26
- package/test/unit/spec/services/service-registry.js +128 -170
- package/test/unit/spec/services/service-state.js +13 -22
- package/test/unit/spec/services/service-url.js +24 -43
- package/test/unit/spec/services/services.js +85 -41
- package/test/unit/spec/storage/persist.js +6 -9
- package/test/unit/spec/storage/wait-for-value.js +22 -21
- package/test/unit/spec/webex-core.js +78 -57
- package/test/unit/spec/webex-internal-core.js +56 -31
|
@@ -12,37 +12,45 @@ const ServiceCatalog = AmpState.extend({
|
|
|
12
12
|
namespace: 'ServiceCatalog',
|
|
13
13
|
|
|
14
14
|
props: {
|
|
15
|
-
serviceGroups: [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
15
|
+
serviceGroups: [
|
|
16
|
+
'object',
|
|
17
|
+
true,
|
|
18
|
+
() => ({
|
|
19
|
+
discovery: [],
|
|
20
|
+
override: [],
|
|
21
|
+
preauth: [],
|
|
22
|
+
postauth: [],
|
|
23
|
+
signin: [],
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
status: [
|
|
27
|
+
'object',
|
|
28
|
+
true,
|
|
29
|
+
() => ({
|
|
30
|
+
discovery: {
|
|
31
|
+
ready: false,
|
|
32
|
+
collecting: false,
|
|
33
|
+
},
|
|
34
|
+
override: {
|
|
35
|
+
ready: false,
|
|
36
|
+
collecting: false,
|
|
37
|
+
},
|
|
38
|
+
preauth: {
|
|
39
|
+
ready: false,
|
|
40
|
+
collecting: false,
|
|
41
|
+
},
|
|
42
|
+
postauth: {
|
|
43
|
+
ready: false,
|
|
44
|
+
collecting: false,
|
|
45
|
+
},
|
|
46
|
+
signin: {
|
|
47
|
+
ready: false,
|
|
48
|
+
collecting: false,
|
|
49
|
+
},
|
|
50
|
+
}),
|
|
51
|
+
],
|
|
44
52
|
isReady: ['boolean', false, false],
|
|
45
|
-
allowedDomains: ['array', false, (
|
|
53
|
+
allowedDomains: ['array', false, () => []],
|
|
46
54
|
},
|
|
47
55
|
|
|
48
56
|
/**
|
|
@@ -54,15 +62,16 @@ const ServiceCatalog = AmpState.extend({
|
|
|
54
62
|
* @returns {ServiceUrl}
|
|
55
63
|
*/
|
|
56
64
|
_getUrl(name, serviceGroup) {
|
|
57
|
-
const serviceUrls =
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
const serviceUrls =
|
|
66
|
+
typeof serviceGroup === 'string'
|
|
67
|
+
? this.serviceGroups[serviceGroup] || []
|
|
68
|
+
: [
|
|
69
|
+
...this.serviceGroups.override,
|
|
70
|
+
...this.serviceGroups.postauth,
|
|
71
|
+
...this.serviceGroups.signin,
|
|
72
|
+
...this.serviceGroups.preauth,
|
|
73
|
+
...this.serviceGroups.discovery,
|
|
74
|
+
];
|
|
66
75
|
|
|
67
76
|
return serviceUrls.find((serviceUrl) => serviceUrl.name === name);
|
|
68
77
|
},
|
|
@@ -79,7 +88,7 @@ const ServiceCatalog = AmpState.extend({
|
|
|
79
88
|
...this.serviceGroups.postauth,
|
|
80
89
|
...this.serviceGroups.signin,
|
|
81
90
|
...this.serviceGroups.preauth,
|
|
82
|
-
...this.serviceGroups.discovery
|
|
91
|
+
...this.serviceGroups.discovery,
|
|
83
92
|
];
|
|
84
93
|
},
|
|
85
94
|
|
|
@@ -121,7 +130,8 @@ const ServiceCatalog = AmpState.extend({
|
|
|
121
130
|
|
|
122
131
|
if (existingService) {
|
|
123
132
|
this.serviceGroups[serviceGroup].splice(
|
|
124
|
-
this.serviceGroups[serviceGroup].indexOf(existingService),
|
|
133
|
+
this.serviceGroups[serviceGroup].indexOf(existingService),
|
|
134
|
+
1
|
|
125
135
|
);
|
|
126
136
|
}
|
|
127
137
|
});
|
|
@@ -163,8 +173,7 @@ const ServiceCatalog = AmpState.extend({
|
|
|
163
173
|
}
|
|
164
174
|
}
|
|
165
175
|
|
|
166
|
-
if (serviceUrlObj.hostname === incomingUrlObj.hostname &&
|
|
167
|
-
service.hosts.length > 0) {
|
|
176
|
+
if (serviceUrlObj.hostname === incomingUrlObj.hostname && service.hosts.length > 0) {
|
|
168
177
|
// no exact match, so try to grab the first home cluster
|
|
169
178
|
for (const host of service.hosts) {
|
|
170
179
|
if (host.homeCluster) {
|
|
@@ -196,25 +205,25 @@ const ServiceCatalog = AmpState.extend({
|
|
|
196
205
|
* @returns {string} service.url
|
|
197
206
|
*/
|
|
198
207
|
findServiceFromClusterId({clusterId, priorityHost = true, serviceGroup} = {}) {
|
|
199
|
-
const serviceUrls =
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
)
|
|
208
|
+
const serviceUrls =
|
|
209
|
+
typeof serviceGroup === 'string'
|
|
210
|
+
? this.serviceGroups[serviceGroup] || []
|
|
211
|
+
: [
|
|
212
|
+
...this.serviceGroups.override,
|
|
213
|
+
...this.serviceGroups.postauth,
|
|
214
|
+
...this.serviceGroups.signin,
|
|
215
|
+
...this.serviceGroups.preauth,
|
|
216
|
+
...this.serviceGroups.discovery,
|
|
217
|
+
];
|
|
218
|
+
|
|
219
|
+
const identifiedServiceUrl = serviceUrls.find((serviceUrl) =>
|
|
220
|
+
serviceUrl.hosts.find((host) => host.id === clusterId)
|
|
212
221
|
);
|
|
213
222
|
|
|
214
223
|
if (identifiedServiceUrl) {
|
|
215
224
|
return {
|
|
216
225
|
name: identifiedServiceUrl.name,
|
|
217
|
-
url: identifiedServiceUrl.get(priorityHost, clusterId)
|
|
226
|
+
url: identifiedServiceUrl.get(priorityHost, clusterId),
|
|
218
227
|
};
|
|
219
228
|
}
|
|
220
229
|
|
|
@@ -233,23 +242,20 @@ const ServiceCatalog = AmpState.extend({
|
|
|
233
242
|
...this.serviceGroups.preauth,
|
|
234
243
|
...this.serviceGroups.signin,
|
|
235
244
|
...this.serviceGroups.postauth,
|
|
236
|
-
...this.serviceGroups.override
|
|
245
|
+
...this.serviceGroups.override,
|
|
237
246
|
];
|
|
238
247
|
|
|
239
|
-
return serviceUrls.find(
|
|
240
|
-
(serviceUrl)
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
return true;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
if (serviceUrl.hosts.find((host) => host.host === incomingUrlObj.hostname)) {
|
|
247
|
-
return true;
|
|
248
|
-
}
|
|
248
|
+
return serviceUrls.find((serviceUrl) => {
|
|
249
|
+
if (incomingUrlObj.hostname === Url.parse(serviceUrl.defaultUrl).hostname) {
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
249
252
|
|
|
250
|
-
|
|
253
|
+
if (serviceUrl.hosts.find((host) => host.host === incomingUrlObj.hostname)) {
|
|
254
|
+
return true;
|
|
251
255
|
}
|
|
252
|
-
|
|
256
|
+
|
|
257
|
+
return false;
|
|
258
|
+
});
|
|
253
259
|
},
|
|
254
260
|
|
|
255
261
|
/**
|
|
@@ -265,9 +271,7 @@ const ServiceCatalog = AmpState.extend({
|
|
|
265
271
|
return undefined;
|
|
266
272
|
}
|
|
267
273
|
|
|
268
|
-
return this.allowedDomains.find(
|
|
269
|
-
(allowedDomain) => urlObj.host.includes(allowedDomain)
|
|
270
|
-
);
|
|
274
|
+
return this.allowedDomains.find((allowedDomain) => urlObj.host.includes(allowedDomain));
|
|
271
275
|
},
|
|
272
276
|
|
|
273
277
|
/**
|
|
@@ -280,7 +284,7 @@ const ServiceCatalog = AmpState.extend({
|
|
|
280
284
|
get(name, priorityHost, serviceGroup) {
|
|
281
285
|
const serviceUrl = this._getUrl(name, serviceGroup);
|
|
282
286
|
|
|
283
|
-
return
|
|
287
|
+
return serviceUrl ? serviceUrl.get(priorityHost) : undefined;
|
|
284
288
|
},
|
|
285
289
|
|
|
286
290
|
/**
|
|
@@ -302,15 +306,16 @@ const ServiceCatalog = AmpState.extend({
|
|
|
302
306
|
list(priorityHost, serviceGroup) {
|
|
303
307
|
const output = {};
|
|
304
308
|
|
|
305
|
-
const serviceUrls =
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
309
|
+
const serviceUrls =
|
|
310
|
+
typeof serviceGroup === 'string'
|
|
311
|
+
? this.serviceGroups[serviceGroup] || []
|
|
312
|
+
: [
|
|
313
|
+
...this.serviceGroups.discovery,
|
|
314
|
+
...this.serviceGroups.preauth,
|
|
315
|
+
...this.serviceGroups.signin,
|
|
316
|
+
...this.serviceGroups.postauth,
|
|
317
|
+
...this.serviceGroups.override,
|
|
318
|
+
];
|
|
314
319
|
|
|
315
320
|
if (serviceUrls) {
|
|
316
321
|
serviceUrls.forEach((serviceUrl) => {
|
|
@@ -335,15 +340,15 @@ const ServiceCatalog = AmpState.extend({
|
|
|
335
340
|
* @returns {string}
|
|
336
341
|
*/
|
|
337
342
|
markFailedUrl(url, noPriorityHosts) {
|
|
338
|
-
const serviceUrl = this._getUrl(
|
|
339
|
-
(key) => this._getUrl(key).failHost(url)
|
|
340
|
-
)
|
|
343
|
+
const serviceUrl = this._getUrl(
|
|
344
|
+
Object.keys(this.list()).find((key) => this._getUrl(key).failHost(url))
|
|
345
|
+
);
|
|
341
346
|
|
|
342
347
|
if (!serviceUrl) {
|
|
343
348
|
return undefined;
|
|
344
349
|
}
|
|
345
350
|
|
|
346
|
-
return
|
|
351
|
+
return noPriorityHosts ? serviceUrl.get(false) : serviceUrl.get(true);
|
|
347
352
|
},
|
|
348
353
|
|
|
349
354
|
/**
|
|
@@ -368,10 +373,8 @@ const ServiceCatalog = AmpState.extend({
|
|
|
368
373
|
updateServiceUrls(serviceGroup, serviceHostmap) {
|
|
369
374
|
const currentServiceUrls = this.serviceGroups[serviceGroup];
|
|
370
375
|
|
|
371
|
-
const unusedUrls = currentServiceUrls.filter(
|
|
372
|
-
(
|
|
373
|
-
(item) => item.name !== serviceUrl.name
|
|
374
|
-
)
|
|
376
|
+
const unusedUrls = currentServiceUrls.filter((serviceUrl) =>
|
|
377
|
+
serviceHostmap.every((item) => item.name !== serviceUrl.name)
|
|
375
378
|
);
|
|
376
379
|
|
|
377
380
|
this._unloadServiceUrls(serviceGroup, unusedUrls);
|
|
@@ -382,11 +385,12 @@ const ServiceCatalog = AmpState.extend({
|
|
|
382
385
|
if (service) {
|
|
383
386
|
service.defaultUrl = serviceObj.defaultUrl;
|
|
384
387
|
service.hosts = serviceObj.hosts || [];
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
388
|
+
} else {
|
|
389
|
+
this._loadServiceUrls(serviceGroup, [
|
|
390
|
+
new ServiceUrl({
|
|
391
|
+
...serviceObj,
|
|
392
|
+
}),
|
|
393
|
+
]);
|
|
390
394
|
}
|
|
391
395
|
});
|
|
392
396
|
|
|
@@ -409,16 +413,22 @@ const ServiceCatalog = AmpState.extend({
|
|
|
409
413
|
resolve();
|
|
410
414
|
}
|
|
411
415
|
|
|
412
|
-
const timeoutTimer = setTimeout(
|
|
413
|
-
|
|
414
|
-
|
|
416
|
+
const timeoutTimer = setTimeout(
|
|
417
|
+
() =>
|
|
418
|
+
reject(
|
|
419
|
+
new Error(
|
|
420
|
+
`services: timeout occured while waiting for '${serviceGroup}' catalog to populate`
|
|
421
|
+
)
|
|
422
|
+
),
|
|
423
|
+
timeout ? timeout * 1000 : 60000
|
|
424
|
+
);
|
|
415
425
|
|
|
416
426
|
this.once(serviceGroup, () => {
|
|
417
427
|
clearTimeout(timeoutTimer);
|
|
418
428
|
resolve();
|
|
419
429
|
});
|
|
420
430
|
});
|
|
421
|
-
}
|
|
431
|
+
},
|
|
422
432
|
});
|
|
423
433
|
/* eslint-enable no-underscore-dangle */
|
|
424
434
|
|
|
@@ -133,7 +133,7 @@ export default class ServiceHost {
|
|
|
133
133
|
*/
|
|
134
134
|
get active() {
|
|
135
135
|
// Validate that the `ServiceHost` was not marked as failed or replaced.
|
|
136
|
-
return
|
|
136
|
+
return !this.failed && !this.replaced;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
/**
|
|
@@ -212,9 +212,9 @@ export default class ServiceHost {
|
|
|
212
212
|
catalog,
|
|
213
213
|
defaultUri: url,
|
|
214
214
|
hostGroup: Url.parse(url).host,
|
|
215
|
-
id:
|
|
215
|
+
id: name ? `poly-head:poly-group:poly-cluster:${name}` : undefined,
|
|
216
216
|
priority: 1,
|
|
217
|
-
uri: Url.parse(url).host
|
|
217
|
+
uri: Url.parse(url).host,
|
|
218
218
|
});
|
|
219
219
|
}
|
|
220
220
|
|
|
@@ -228,14 +228,7 @@ export default class ServiceHost {
|
|
|
228
228
|
* @throws - If the parameter transfer object is not valid.
|
|
229
229
|
* @returns {undefined}
|
|
230
230
|
*/
|
|
231
|
-
static validate({
|
|
232
|
-
catalog,
|
|
233
|
-
defaultUri,
|
|
234
|
-
hostGroup,
|
|
235
|
-
id,
|
|
236
|
-
priority,
|
|
237
|
-
uri
|
|
238
|
-
}) {
|
|
231
|
+
static validate({catalog, defaultUri, hostGroup, id, priority, uri}) {
|
|
239
232
|
// Generate error-throwing method.
|
|
240
233
|
const throwError = (msg) => {
|
|
241
234
|
throw new Error(`service-host: invalid constructor parameters, ${msg}`);
|
|
@@ -243,32 +236,32 @@ export default class ServiceHost {
|
|
|
243
236
|
|
|
244
237
|
// Validate the catalog property.
|
|
245
238
|
if (!SERVICE_CATALOGS.includes(catalog)) {
|
|
246
|
-
throwError('
|
|
239
|
+
throwError("'catalog' must be a string");
|
|
247
240
|
}
|
|
248
241
|
|
|
249
242
|
// Validate the `defaultUri` property.
|
|
250
243
|
if (typeof defaultUri !== 'string') {
|
|
251
|
-
throwError('
|
|
244
|
+
throwError("'defaultUri' must be a string");
|
|
252
245
|
}
|
|
253
246
|
|
|
254
247
|
// Validate the `hostGroup` property.
|
|
255
248
|
if (typeof hostGroup !== 'string') {
|
|
256
|
-
throwError('
|
|
249
|
+
throwError("'hostGroup' must be a string");
|
|
257
250
|
}
|
|
258
251
|
|
|
259
252
|
// Validate the `id` property.
|
|
260
253
|
if (typeof id !== 'string' || id.split(':').length !== 4) {
|
|
261
|
-
throwError('
|
|
254
|
+
throwError("'id' must be a string that contains 3 ':' characters");
|
|
262
255
|
}
|
|
263
256
|
|
|
264
257
|
// Validate the `priority` property.
|
|
265
258
|
if (typeof priority !== 'number') {
|
|
266
|
-
throwError('
|
|
259
|
+
throwError("'priority' must be a number");
|
|
267
260
|
}
|
|
268
261
|
|
|
269
262
|
// Validate the `uri` property.
|
|
270
263
|
if (typeof uri !== 'string') {
|
|
271
|
-
throwError('
|
|
264
|
+
throwError("'uri' must be a string");
|
|
272
265
|
}
|
|
273
266
|
}
|
|
274
267
|
}
|