@thisisagile/easy 10.10.3 → 10.10.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/utils/{Retry.d.ts → Rerun.d.ts} +2 -2
- package/dist/utils/{Retry.js → Rerun.js} +8 -8
- package/dist/utils/{Retry.js.map → Rerun.js.map} +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/package.json +2 -2
- package/src/utils/{Retry.ts → Rerun.ts} +5 -5
- package/src/utils/index.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ErrorOrigin } from '../types';
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class Rerun<T = any> {
|
|
3
3
|
readonly subject: () => Promise<T>;
|
|
4
4
|
readonly times: number;
|
|
5
5
|
readonly interval: number;
|
|
@@ -7,4 +7,4 @@ export declare class Retry<T = any> {
|
|
|
7
7
|
constructor(subject: () => Promise<T>, times?: number, interval?: number, prevError?: ErrorOrigin | undefined);
|
|
8
8
|
run: () => Promise<T>;
|
|
9
9
|
}
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const rerun: <T>(subject: () => Promise<T>, times?: number | undefined, interval?: number | undefined, prevError?: ErrorOrigin | undefined) => Promise<T>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.rerun = exports.Rerun = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
|
-
const validation_1 = require("../validation");
|
|
6
5
|
const Wait_1 = require("./Wait");
|
|
7
|
-
|
|
6
|
+
const validation_1 = require("../validation");
|
|
7
|
+
class Rerun {
|
|
8
8
|
constructor(subject, times = 3, interval = 1000, prevError) {
|
|
9
9
|
this.subject = subject;
|
|
10
10
|
this.times = times;
|
|
@@ -14,11 +14,11 @@ class Retry {
|
|
|
14
14
|
.not.isTrue.reject(this.prevError ?? types_1.Exception.CouldNotExecute)
|
|
15
15
|
.then(() => this.subject().catch(async (e) => {
|
|
16
16
|
await (0, Wait_1.wait)(this.interval);
|
|
17
|
-
return new
|
|
17
|
+
return new Rerun(this.subject, this.times - 1, this.interval, e).run();
|
|
18
18
|
}));
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
exports.
|
|
22
|
-
const
|
|
23
|
-
exports.
|
|
24
|
-
//# sourceMappingURL=
|
|
21
|
+
exports.Rerun = Rerun;
|
|
22
|
+
const rerun = (subject, times, interval, prevError) => new Rerun(subject, times, interval, prevError).run();
|
|
23
|
+
exports.rerun = rerun;
|
|
24
|
+
//# sourceMappingURL=Rerun.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"Rerun.js","sourceRoot":"","sources":["../../src/utils/Rerun.ts"],"names":[],"mappings":";;;AAAA,oCAAkD;AAClD,iCAA8B;AAC9B,8CAAqC;AAErC,MAAa,KAAK;IAChB,YAAqB,OAAyB,EAAW,QAAQ,CAAC,EAAW,WAAW,IAAI,EAAW,SAAuB;QAAzG,YAAO,GAAP,OAAO,CAAkB;QAAW,UAAK,GAAL,KAAK,CAAI;QAAW,aAAQ,GAAR,QAAQ,CAAO;QAAW,cAAS,GAAT,SAAS,CAAc;QAE9H,QAAG,GAAG,GAAe,EAAE,CACrB,IAAA,iBAAI,EAAC,IAAI,CAAC,KAAK,CAAC;aACb,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,IAAI,iBAAS,CAAC,eAAe,CAAC;aAC9D,IAAI,CAAC,GAAG,EAAE,CACT,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,KAAK,EAAC,CAAC,EAAC,EAAE;YAC7B,MAAM,IAAA,WAAI,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC1B,OAAO,IAAI,KAAK,CAAI,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;QAC5E,CAAC,CAAC,CACH,CAAC;IAV2H,CAAC;CAWnI;AAZD,sBAYC;AAEM,MAAM,KAAK,GAAG,CAAI,OAAyB,EAAE,KAAc,EAAE,QAAiB,EAAE,SAAuB,EAAc,EAAE,CAC5H,IAAI,KAAK,CAAI,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,GAAG,EAAE,CAAC;AAD7C,QAAA,KAAK,SACwC"}
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -20,7 +20,7 @@ __exportStar(require("./Log"), exports);
|
|
|
20
20
|
__exportStar(require("./Mapper"), exports);
|
|
21
21
|
__exportStar(require("./Promise"), exports);
|
|
22
22
|
__exportStar(require("./Property"), exports);
|
|
23
|
-
__exportStar(require("./
|
|
23
|
+
__exportStar(require("./Rerun"), exports);
|
|
24
24
|
__exportStar(require("./State"), exports);
|
|
25
25
|
__exportStar(require("./Sentence"), exports);
|
|
26
26
|
__exportStar(require("./Traverse"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thisisagile/easy",
|
|
3
|
-
"version": "10.10.
|
|
3
|
+
"version": "10.10.4",
|
|
4
4
|
"description": "Straightforward library for building domain-driven microservice architectures",
|
|
5
5
|
"author": "Sander Hoogendoorn",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@thisisagile/easy-test": "10.10.
|
|
34
|
+
"@thisisagile/easy-test": "10.10.4",
|
|
35
35
|
"@types/form-urlencoded": "^4.4.0",
|
|
36
36
|
"@types/jsonwebtoken": "^8.5.8",
|
|
37
37
|
"@types/validator": "^13.7.2"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ErrorOrigin, Exception } from '../types';
|
|
2
|
-
import { when } from '../validation';
|
|
3
2
|
import { wait } from './Wait';
|
|
3
|
+
import { when } from '../validation';
|
|
4
4
|
|
|
5
|
-
export class
|
|
5
|
+
export class Rerun<T = any> {
|
|
6
6
|
constructor(readonly subject: () => Promise<T>, readonly times = 3, readonly interval = 1000, readonly prevError?: ErrorOrigin) {}
|
|
7
7
|
|
|
8
8
|
run = (): Promise<T> =>
|
|
@@ -11,10 +11,10 @@ export class Retry<T = any> {
|
|
|
11
11
|
.then(() =>
|
|
12
12
|
this.subject().catch(async e => {
|
|
13
13
|
await wait(this.interval);
|
|
14
|
-
return new
|
|
14
|
+
return new Rerun<T>(this.subject, this.times - 1, this.interval, e).run();
|
|
15
15
|
})
|
|
16
16
|
);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export const
|
|
20
|
-
new
|
|
19
|
+
export const rerun = <T>(subject: () => Promise<T>, times?: number, interval?: number, prevError?: ErrorOrigin): Promise<T> =>
|
|
20
|
+
new Rerun<T>(subject, times, interval, prevError).run();
|
package/src/utils/index.ts
CHANGED