@motifx/core 1.2.0-rc.2 → 1.2.0-rc.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/README.md +1 -2
- package/dist/chunks/{core-C5z0P3iY.esm.js → core-C-BpS-QN.esm.js} +1092 -834
- package/dist/chunks/core-C-BpS-QN.esm.js.map +1 -0
- package/dist/chunks/{core-CX1Sz73P.cjs → core-ZMoM1273.cjs} +1094 -833
- package/dist/chunks/core-ZMoM1273.cjs.map +1 -0
- package/dist/devtools.cjs +1 -1
- package/dist/devtools.esm.js +1 -1
- package/dist/index.cjs +101 -156
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -19
- package/dist/index.d.ts +46 -19
- package/dist/index.esm.js +92 -147
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.umd.js +1162 -959
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/core-C5z0P3iY.esm.js.map +0 -1
- package/dist/chunks/core-CX1Sz73P.cjs.map +0 -1
package/dist/devtools.cjs
CHANGED
package/dist/devtools.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { a6 as debugGetDepMap, a5 as debugGetDeps } from './chunks/core-C-BpS-QN.esm.js';
|
|
2
2
|
//# sourceMappingURL=devtools.esm.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var devtools = require('./chunks/core-
|
|
3
|
+
var devtools = require('./chunks/core-ZMoM1273.cjs');
|
|
4
4
|
|
|
5
5
|
class NameValuePair {
|
|
6
|
-
Key;
|
|
7
|
-
value;
|
|
8
6
|
}
|
|
9
7
|
|
|
10
8
|
class List {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
_map = new Set();
|
|
9
|
+
constructor() {
|
|
10
|
+
this.__list = [];
|
|
11
|
+
this._map = new Set();
|
|
12
|
+
}
|
|
16
13
|
Dispose() {
|
|
17
14
|
this.__list = [];
|
|
18
15
|
}
|
|
@@ -94,7 +91,9 @@ class List {
|
|
|
94
91
|
}
|
|
95
92
|
|
|
96
93
|
class Dictionary {
|
|
97
|
-
|
|
94
|
+
constructor() {
|
|
95
|
+
this.__values = new List();
|
|
96
|
+
}
|
|
98
97
|
Add(Key, Value) {
|
|
99
98
|
var item = new NameValuePair();
|
|
100
99
|
item.Key = Key;
|
|
@@ -111,7 +110,6 @@ class Dictionary {
|
|
|
111
110
|
item(key) {
|
|
112
111
|
return this.filter(t => t.Key == key)[0];
|
|
113
112
|
}
|
|
114
|
-
OnItemAdded;
|
|
115
113
|
removeIndex(index) {
|
|
116
114
|
return this.__values.removeIndex(index);
|
|
117
115
|
}
|
|
@@ -152,7 +150,6 @@ function compareKeys(a, b) {
|
|
|
152
150
|
return a > b ? 1 : a < b ? -1 : 0;
|
|
153
151
|
}
|
|
154
152
|
class Query {
|
|
155
|
-
source;
|
|
156
153
|
constructor(source) {
|
|
157
154
|
this.source = Array.isArray(source) ? source : Array.from(source);
|
|
158
155
|
}
|
|
@@ -302,39 +299,19 @@ class ContentBody extends devtools.Component {
|
|
|
302
299
|
}
|
|
303
300
|
}
|
|
304
301
|
|
|
305
|
-
const SLOT_REGISTERED_EVENT = Symbol('slotRegistered');
|
|
306
|
-
const SLOT_UNREGISTERED_EVENT = Symbol('slotUnregistered');
|
|
307
|
-
class TransportRegistry {
|
|
308
|
-
static slots = new Map();
|
|
309
|
-
static registerSlot(name, slot) {
|
|
310
|
-
this.slots.set(name, slot);
|
|
311
|
-
devtools.Application.main.fire(SLOT_REGISTERED_EVENT, { name, slot });
|
|
312
|
-
}
|
|
313
|
-
static unregisterSlot(name, slot) {
|
|
314
|
-
if (this.slots.get(name) === slot) {
|
|
315
|
-
this.slots.delete(name);
|
|
316
|
-
devtools.Application.main.fire(SLOT_UNREGISTERED_EVENT, { name, slot });
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
static getSlot(name) {
|
|
320
|
-
return this.slots.get(name);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
302
|
class Transport extends devtools.Component {
|
|
325
|
-
mode;
|
|
326
303
|
constructor(props) {
|
|
327
304
|
super(props);
|
|
328
305
|
this.mode = props.mode || 'replace';
|
|
329
306
|
}
|
|
330
307
|
initializeComponent(sender) {
|
|
331
|
-
TransportRegistry.registerSlot(this.props.name, this);
|
|
308
|
+
devtools.TransportRegistry.registerSlot(this.props.name, this);
|
|
332
309
|
this.onDisposing = () => {
|
|
333
310
|
[...(this.controls.items || [])].forEach(child => {
|
|
334
311
|
this.controls.remove(child);
|
|
335
312
|
child.dispose?.();
|
|
336
313
|
});
|
|
337
|
-
TransportRegistry.unregisterSlot(this.props.name, this);
|
|
314
|
+
devtools.TransportRegistry.unregisterSlot(this.props.name, this);
|
|
338
315
|
};
|
|
339
316
|
}
|
|
340
317
|
clearSlot() {
|
|
@@ -410,28 +387,34 @@ class Transporter {
|
|
|
410
387
|
}
|
|
411
388
|
|
|
412
389
|
class TransportTo extends devtools.Component {
|
|
413
|
-
_onAddRef;
|
|
414
|
-
_onRemoveRef;
|
|
415
|
-
_slotRegisteredListener;
|
|
416
|
-
_slotUnregisteredListener;
|
|
417
|
-
_transported = [];
|
|
418
|
-
_countedLive = false;
|
|
419
390
|
constructor(props) {
|
|
420
391
|
super('div', props);
|
|
392
|
+
this._transported = [];
|
|
393
|
+
this._countedLive = false;
|
|
394
|
+
this._handleSlotChange = (eventArgs) => {
|
|
395
|
+
if (eventArgs.name === this.props.name) {
|
|
396
|
+
const slot = eventArgs.slot;
|
|
397
|
+
if (slot.mode !== 'merge') {
|
|
398
|
+
slot.clearSlot?.();
|
|
399
|
+
}
|
|
400
|
+
const all = [...(this.childs || []), ...this.controls.items];
|
|
401
|
+
Transporter.transportMany(all, slot);
|
|
402
|
+
this._rememberTransported(all);
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
this._clearChildrenFromSlot = (slot) => {
|
|
406
|
+
(this.childs || []).forEach(child => {
|
|
407
|
+
slot.controls.remove(child);
|
|
408
|
+
child.dispose();
|
|
409
|
+
});
|
|
410
|
+
(this.controls.items || []).forEach(child => {
|
|
411
|
+
slot.controls.remove(child);
|
|
412
|
+
child.dispose();
|
|
413
|
+
});
|
|
414
|
+
};
|
|
421
415
|
devtools.contentBlocks.live++;
|
|
422
416
|
this._countedLive = true;
|
|
423
417
|
}
|
|
424
|
-
_handleSlotChange = (eventArgs) => {
|
|
425
|
-
if (eventArgs.name === this.props.name) {
|
|
426
|
-
const slot = eventArgs.slot;
|
|
427
|
-
if (slot.mode !== 'merge') {
|
|
428
|
-
slot.clearSlot?.();
|
|
429
|
-
}
|
|
430
|
-
const all = [...(this.childs || []), ...this.controls.items];
|
|
431
|
-
Transporter.transportMany(all, slot);
|
|
432
|
-
this._rememberTransported(all);
|
|
433
|
-
}
|
|
434
|
-
};
|
|
435
418
|
_rememberTransported(children) {
|
|
436
419
|
const kept = this._transported.filter(c => !c.isDisposed);
|
|
437
420
|
for (const child of children) {
|
|
@@ -440,18 +423,8 @@ class TransportTo extends devtools.Component {
|
|
|
440
423
|
}
|
|
441
424
|
this._transported = kept;
|
|
442
425
|
}
|
|
443
|
-
_clearChildrenFromSlot = (slot) => {
|
|
444
|
-
(this.childs || []).forEach(child => {
|
|
445
|
-
slot.controls.remove(child);
|
|
446
|
-
child.dispose();
|
|
447
|
-
});
|
|
448
|
-
(this.controls.items || []).forEach(child => {
|
|
449
|
-
slot.controls.remove(child);
|
|
450
|
-
child.dispose();
|
|
451
|
-
});
|
|
452
|
-
};
|
|
453
426
|
initializeComponent(sender) {
|
|
454
|
-
let slot = TransportRegistry.getSlot(this.props.name);
|
|
427
|
+
let slot = devtools.TransportRegistry.getSlot(this.props.name);
|
|
455
428
|
if (slot) {
|
|
456
429
|
if (slot.mode !== 'merge') {
|
|
457
430
|
slot.clearSlot?.();
|
|
@@ -460,22 +433,22 @@ class TransportTo extends devtools.Component {
|
|
|
460
433
|
Transporter.transportMany(all, slot);
|
|
461
434
|
this._rememberTransported(all);
|
|
462
435
|
}
|
|
463
|
-
this._slotRegisteredListener = devtools.Application.main.on(SLOT_REGISTERED_EVENT, this._handleSlotChange);
|
|
464
|
-
this._slotUnregisteredListener = devtools.Application.main.on(SLOT_UNREGISTERED_EVENT, (eventArgs) => {
|
|
436
|
+
this._slotRegisteredListener = devtools.Application.main.on(devtools.SLOT_REGISTERED_EVENT, this._handleSlotChange);
|
|
437
|
+
this._slotUnregisteredListener = devtools.Application.main.on(devtools.SLOT_UNREGISTERED_EVENT, (eventArgs) => {
|
|
465
438
|
if (eventArgs.name === this.props.name) {
|
|
466
439
|
this._clearChildrenFromSlot(eventArgs.slot);
|
|
467
440
|
}
|
|
468
441
|
});
|
|
469
442
|
this._onAddRef = (child) => {
|
|
470
443
|
this.motif.trigger('controladded', { control: child });
|
|
471
|
-
const currentSlot = TransportRegistry.getSlot(this.props.name);
|
|
444
|
+
const currentSlot = devtools.TransportRegistry.getSlot(this.props.name);
|
|
472
445
|
if (currentSlot) {
|
|
473
446
|
Transporter.transport(child, currentSlot);
|
|
474
447
|
this._rememberTransported([child]);
|
|
475
448
|
}
|
|
476
449
|
};
|
|
477
450
|
this._onRemoveRef = (child) => {
|
|
478
|
-
const currentSlot = TransportRegistry.getSlot(this.props.name);
|
|
451
|
+
const currentSlot = devtools.TransportRegistry.getSlot(this.props.name);
|
|
479
452
|
if (currentSlot) {
|
|
480
453
|
currentSlot.controls.remove(child);
|
|
481
454
|
}
|
|
@@ -489,17 +462,17 @@ class TransportTo extends devtools.Component {
|
|
|
489
462
|
this._countedLive = false;
|
|
490
463
|
devtools.contentBlocks.live--;
|
|
491
464
|
}
|
|
492
|
-
const currentSlot = TransportRegistry.getSlot(this.props.name);
|
|
465
|
+
const currentSlot = devtools.TransportRegistry.getSlot(this.props.name);
|
|
493
466
|
for (const child of this._transported || []) {
|
|
494
467
|
currentSlot?.controls.remove(child);
|
|
495
468
|
child.dispose();
|
|
496
469
|
}
|
|
497
470
|
if (this._slotRegisteredListener) {
|
|
498
|
-
devtools.Application.main.off(SLOT_REGISTERED_EVENT, this._handleSlotChange);
|
|
471
|
+
devtools.Application.main.off(devtools.SLOT_REGISTERED_EVENT, this._handleSlotChange);
|
|
499
472
|
this._slotRegisteredListener = undefined;
|
|
500
473
|
}
|
|
501
474
|
if (this._slotUnregisteredListener) {
|
|
502
|
-
devtools.Application.main.off(SLOT_UNREGISTERED_EVENT, this._slotUnregisteredListener);
|
|
475
|
+
devtools.Application.main.off(devtools.SLOT_UNREGISTERED_EVENT, this._slotUnregisteredListener);
|
|
503
476
|
this._slotUnregisteredListener = undefined;
|
|
504
477
|
}
|
|
505
478
|
if (this.controls.onAdd === this._onAddRef)
|
|
@@ -513,19 +486,35 @@ class TransportTo extends devtools.Component {
|
|
|
513
486
|
}
|
|
514
487
|
|
|
515
488
|
class Virtualization extends devtools.Component {
|
|
516
|
-
_state;
|
|
517
|
-
_virtualContent;
|
|
518
|
-
_topSpacer;
|
|
519
|
-
_bottomSpacer;
|
|
520
|
-
_cache = new Map();
|
|
521
|
-
_view = [];
|
|
522
|
-
_occurrence = [];
|
|
523
|
-
_occurrenceKeys = new WeakMap();
|
|
524
|
-
_isLoadingMore = false;
|
|
525
|
-
_emptyRendered = false;
|
|
526
|
-
_renderPending = false;
|
|
527
489
|
constructor(props) {
|
|
528
490
|
super('div', props);
|
|
491
|
+
this._cache = new Map();
|
|
492
|
+
this._view = [];
|
|
493
|
+
this._occurrence = [];
|
|
494
|
+
this._occurrenceKeys = new WeakMap();
|
|
495
|
+
this._isLoadingMore = false;
|
|
496
|
+
this._emptyRendered = false;
|
|
497
|
+
this._renderPending = false;
|
|
498
|
+
this.contentWrapper = new devtools.Component();
|
|
499
|
+
this._initialLoadStarted = false;
|
|
500
|
+
this._offsets = null;
|
|
501
|
+
this._observedHeight = -1;
|
|
502
|
+
this._loadSeq = 0;
|
|
503
|
+
this._reloadScheduled = false;
|
|
504
|
+
this._reloadTimes = [];
|
|
505
|
+
this._handleScroll = (_sender, _event) => {
|
|
506
|
+
this.renderViewport();
|
|
507
|
+
if (this.props.autoLoad === false)
|
|
508
|
+
return;
|
|
509
|
+
if (!this._state.hasMore || this._isLoadingMore || !this._state.isInitialized)
|
|
510
|
+
return;
|
|
511
|
+
const el = this.wrapper.element;
|
|
512
|
+
const fixed = this._fixedHeight();
|
|
513
|
+
const loadedBottom = fixed !== null ? this._state.data.length * fixed : this._offsetOf(this._view.length);
|
|
514
|
+
const distanceToLoaded = loadedBottom - (el.scrollTop + el.clientHeight);
|
|
515
|
+
if (distanceToLoaded < (this.props.autoLoadThreshold ?? 100))
|
|
516
|
+
void this._loadMore();
|
|
517
|
+
};
|
|
529
518
|
if (props.className)
|
|
530
519
|
this.class.add(props.className);
|
|
531
520
|
if (props.style)
|
|
@@ -547,8 +536,6 @@ class Virtualization extends devtools.Component {
|
|
|
547
536
|
this.renderViewport = this.renderViewport.bind(this);
|
|
548
537
|
this._makeView();
|
|
549
538
|
}
|
|
550
|
-
contentWrapper = new devtools.Component();
|
|
551
|
-
wrapper;
|
|
552
539
|
_makeView() {
|
|
553
540
|
this._topSpacer = new devtools.Component('div');
|
|
554
541
|
this._topSpacer.element.style.cssText = 'height: 0px;';
|
|
@@ -577,7 +564,6 @@ class Virtualization extends devtools.Component {
|
|
|
577
564
|
this.motif.on('scroll', this._handleScroll);
|
|
578
565
|
}
|
|
579
566
|
}
|
|
580
|
-
_initialLoadStarted = false;
|
|
581
567
|
onBuilding() {
|
|
582
568
|
if (this.props.mainTemplate || this._initialLoadStarted)
|
|
583
569
|
return;
|
|
@@ -594,10 +580,6 @@ class Virtualization extends devtools.Component {
|
|
|
594
580
|
this._stopDataWatch();
|
|
595
581
|
this._clearContent();
|
|
596
582
|
}
|
|
597
|
-
_offsets = null;
|
|
598
|
-
_resizeObserver;
|
|
599
|
-
_observed;
|
|
600
|
-
_observedHeight = -1;
|
|
601
583
|
_fixedHeight() {
|
|
602
584
|
const h = this.props.itemHeight;
|
|
603
585
|
return typeof h === 'function' ? null : h;
|
|
@@ -679,10 +661,6 @@ class Virtualization extends devtools.Component {
|
|
|
679
661
|
this._resizeObserver = undefined;
|
|
680
662
|
this._observed = undefined;
|
|
681
663
|
}
|
|
682
|
-
_loadSeq = 0;
|
|
683
|
-
_dataWatchStop;
|
|
684
|
-
_reloadScheduled = false;
|
|
685
|
-
_reloadTimes = [];
|
|
686
664
|
_stopDataWatch() {
|
|
687
665
|
this._dataWatchStop?.();
|
|
688
666
|
this._dataWatchStop = undefined;
|
|
@@ -781,19 +759,6 @@ class Virtualization extends devtools.Component {
|
|
|
781
759
|
this._renderErrorState(error);
|
|
782
760
|
}
|
|
783
761
|
}
|
|
784
|
-
_handleScroll = (_sender, _event) => {
|
|
785
|
-
this.renderViewport();
|
|
786
|
-
if (this.props.autoLoad === false)
|
|
787
|
-
return;
|
|
788
|
-
if (!this._state.hasMore || this._isLoadingMore || !this._state.isInitialized)
|
|
789
|
-
return;
|
|
790
|
-
const el = this.wrapper.element;
|
|
791
|
-
const fixed = this._fixedHeight();
|
|
792
|
-
const loadedBottom = fixed !== null ? this._state.data.length * fixed : this._offsetOf(this._view.length);
|
|
793
|
-
const distanceToLoaded = loadedBottom - (el.scrollTop + el.clientHeight);
|
|
794
|
-
if (distanceToLoaded < (this.props.autoLoadThreshold ?? 100))
|
|
795
|
-
void this._loadMore();
|
|
796
|
-
};
|
|
797
762
|
async _loadInitial() {
|
|
798
763
|
const seq = ++this._loadSeq;
|
|
799
764
|
this._state.isLoading = true;
|
|
@@ -1182,12 +1147,6 @@ function addJitter(base, jitterFactor = 0.1) {
|
|
|
1182
1147
|
class Policy {
|
|
1183
1148
|
}
|
|
1184
1149
|
class RetryPolicy extends Policy {
|
|
1185
|
-
retries;
|
|
1186
|
-
backoff;
|
|
1187
|
-
delayMs;
|
|
1188
|
-
jitter;
|
|
1189
|
-
shouldHandle;
|
|
1190
|
-
onRetry;
|
|
1191
1150
|
constructor(options = {}) {
|
|
1192
1151
|
super();
|
|
1193
1152
|
this.retries = options.retries ?? 3;
|
|
@@ -1226,7 +1185,6 @@ class RetryPolicy extends Policy {
|
|
|
1226
1185
|
}
|
|
1227
1186
|
}
|
|
1228
1187
|
class TimeoutPolicy extends Policy {
|
|
1229
|
-
timeoutMs;
|
|
1230
1188
|
constructor(opts) {
|
|
1231
1189
|
super();
|
|
1232
1190
|
this.timeoutMs = opts.timeoutMs;
|
|
@@ -1246,17 +1204,12 @@ class TimeoutPolicy extends Policy {
|
|
|
1246
1204
|
}
|
|
1247
1205
|
}
|
|
1248
1206
|
class CircuitBreakerPolicy extends Policy {
|
|
1249
|
-
failureThreshold;
|
|
1250
|
-
successThreshold;
|
|
1251
|
-
durationOfBreakMs;
|
|
1252
|
-
shouldHandle;
|
|
1253
|
-
onStateChange;
|
|
1254
|
-
state = 'CLOSED';
|
|
1255
|
-
failureCount = 0;
|
|
1256
|
-
successCount = 0;
|
|
1257
|
-
nextAttemptTime = 0;
|
|
1258
1207
|
constructor(opts = {}) {
|
|
1259
1208
|
super();
|
|
1209
|
+
this.state = 'CLOSED';
|
|
1210
|
+
this.failureCount = 0;
|
|
1211
|
+
this.successCount = 0;
|
|
1212
|
+
this.nextAttemptTime = 0;
|
|
1260
1213
|
this.failureThreshold = opts.failureThreshold ?? 5;
|
|
1261
1214
|
this.successThreshold = opts.successThreshold ?? 2;
|
|
1262
1215
|
this.durationOfBreakMs = opts.durationOfBreakMs ?? 60000;
|
|
@@ -1309,12 +1262,10 @@ class CircuitBreakerPolicy extends Policy {
|
|
|
1309
1262
|
}
|
|
1310
1263
|
}
|
|
1311
1264
|
class BulkheadPolicy extends Policy {
|
|
1312
|
-
maxConcurrent;
|
|
1313
|
-
maxQueue;
|
|
1314
|
-
active = 0;
|
|
1315
|
-
queue = [];
|
|
1316
1265
|
constructor(opts = {}) {
|
|
1317
1266
|
super();
|
|
1267
|
+
this.active = 0;
|
|
1268
|
+
this.queue = [];
|
|
1318
1269
|
this.maxConcurrent = opts.maxConcurrent ?? 10;
|
|
1319
1270
|
this.maxQueue = opts.maxQueue ?? 50;
|
|
1320
1271
|
}
|
|
@@ -1347,11 +1298,6 @@ class BulkheadPolicy extends Policy {
|
|
|
1347
1298
|
}
|
|
1348
1299
|
}
|
|
1349
1300
|
class RateLimiterPolicy extends Policy {
|
|
1350
|
-
tokensPerInterval;
|
|
1351
|
-
intervalMs;
|
|
1352
|
-
capacity;
|
|
1353
|
-
tokens;
|
|
1354
|
-
lastRefill;
|
|
1355
1301
|
constructor(opts = {}) {
|
|
1356
1302
|
super();
|
|
1357
1303
|
this.tokensPerInterval = opts.tokensPerInterval ?? 1;
|
|
@@ -1381,8 +1327,6 @@ class RateLimiterPolicy extends Policy {
|
|
|
1381
1327
|
}
|
|
1382
1328
|
}
|
|
1383
1329
|
class FallbackPolicy extends Policy {
|
|
1384
|
-
fallback;
|
|
1385
|
-
shouldHandle;
|
|
1386
1330
|
constructor(opts) {
|
|
1387
1331
|
super();
|
|
1388
1332
|
this.fallback = opts.fallback;
|
|
@@ -1400,7 +1344,6 @@ class FallbackPolicy extends Policy {
|
|
|
1400
1344
|
}
|
|
1401
1345
|
}
|
|
1402
1346
|
class PolicyWrap extends Policy {
|
|
1403
|
-
policies;
|
|
1404
1347
|
constructor(...policies) {
|
|
1405
1348
|
super();
|
|
1406
1349
|
this.policies = policies;
|
|
@@ -1425,34 +1368,36 @@ function decorate(policy, fn) {
|
|
|
1425
1368
|
return (ctx) => policy.execute(fn, ctx);
|
|
1426
1369
|
}
|
|
1427
1370
|
class Resilience {
|
|
1371
|
+
constructor() {
|
|
1372
|
+
this.resiliences = [];
|
|
1373
|
+
this.retry = (opts) => {
|
|
1374
|
+
this.resiliences.push(resilience.retry(opts));
|
|
1375
|
+
return this;
|
|
1376
|
+
};
|
|
1377
|
+
this.timeout = (opts) => {
|
|
1378
|
+
this.resiliences.push(resilience.timeout(opts));
|
|
1379
|
+
return this;
|
|
1380
|
+
};
|
|
1381
|
+
this.circuitBreaker = (opts) => {
|
|
1382
|
+
this.resiliences.push(resilience.circuitBreaker(opts));
|
|
1383
|
+
return this;
|
|
1384
|
+
};
|
|
1385
|
+
this.bulkhead = (opts) => {
|
|
1386
|
+
this.resiliences.push(resilience.bulkhead(opts));
|
|
1387
|
+
return this;
|
|
1388
|
+
};
|
|
1389
|
+
this.rateLimiter = (opts) => {
|
|
1390
|
+
this.resiliences.push(resilience.rateLimiter(opts));
|
|
1391
|
+
return this;
|
|
1392
|
+
};
|
|
1393
|
+
this.fallback = (opts) => {
|
|
1394
|
+
this.resiliences.push(resilience.fallback(opts));
|
|
1395
|
+
return this;
|
|
1396
|
+
};
|
|
1397
|
+
}
|
|
1428
1398
|
static get create() {
|
|
1429
1399
|
return new Resilience();
|
|
1430
1400
|
}
|
|
1431
|
-
resiliences = [];
|
|
1432
|
-
retry = (opts) => {
|
|
1433
|
-
this.resiliences.push(resilience.retry(opts));
|
|
1434
|
-
return this;
|
|
1435
|
-
};
|
|
1436
|
-
timeout = (opts) => {
|
|
1437
|
-
this.resiliences.push(resilience.timeout(opts));
|
|
1438
|
-
return this;
|
|
1439
|
-
};
|
|
1440
|
-
circuitBreaker = (opts) => {
|
|
1441
|
-
this.resiliences.push(resilience.circuitBreaker(opts));
|
|
1442
|
-
return this;
|
|
1443
|
-
};
|
|
1444
|
-
bulkhead = (opts) => {
|
|
1445
|
-
this.resiliences.push(resilience.bulkhead(opts));
|
|
1446
|
-
return this;
|
|
1447
|
-
};
|
|
1448
|
-
rateLimiter = (opts) => {
|
|
1449
|
-
this.resiliences.push(resilience.rateLimiter(opts));
|
|
1450
|
-
return this;
|
|
1451
|
-
};
|
|
1452
|
-
fallback = (opts) => {
|
|
1453
|
-
this.resiliences.push(resilience.fallback(opts));
|
|
1454
|
-
return this;
|
|
1455
|
-
};
|
|
1456
1401
|
async execute(action, ctx) {
|
|
1457
1402
|
return resilience.wrap(...this.resiliences).execute(action, ctx);
|
|
1458
1403
|
}
|