@dromio/workflow-kernel 0.1.7 → 0.1.8
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/cron.d.ts +18 -0
- package/dist/cron.d.ts.map +1 -0
- package/dist/cron.js +223 -0
- package/dist/cron.js.map +1 -0
- package/dist/index.cjs +6802 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/lease.d.ts +21 -0
- package/dist/lease.d.ts.map +1 -0
- package/dist/lease.js +44 -0
- package/dist/lease.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
|
package/dist/lease.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const DEFAULT_LEASE_MS = 60000;
|
|
2
|
+
export declare const DEFAULT_RECONCILE_LIMIT = 100;
|
|
3
|
+
export declare const DEFAULT_CANDIDATE_SCAN_LIMIT = 25;
|
|
4
|
+
export type LeaseRunStatus = "cancelled" | "claimed" | "completed" | "dead" | "failed" | "queued" | "running";
|
|
5
|
+
export type ExpiredLeaseRequeuePatch = {
|
|
6
|
+
claimedAt: null;
|
|
7
|
+
heartbeatAt: null;
|
|
8
|
+
leaseExpiresAt: null;
|
|
9
|
+
nextAttemptAt: Date;
|
|
10
|
+
status: Extract<LeaseRunStatus, "queued">;
|
|
11
|
+
statusReason: string;
|
|
12
|
+
updatedAt: Date;
|
|
13
|
+
workerId: null;
|
|
14
|
+
};
|
|
15
|
+
export declare function retryDelayMsForAttempt(attempt: number): number;
|
|
16
|
+
export declare function retryDelayMsAfterFailedAttempt(attempt: number): number;
|
|
17
|
+
export declare function leaseExpiresAt(now: Date, leaseMs?: number): Date;
|
|
18
|
+
export declare function failedRunStatusForAttempt(attempt: number, maxAttempts: number): Extract<LeaseRunStatus, "dead" | "failed">;
|
|
19
|
+
export declare function expiredLeaseRequeuePatch(now: Date, reason?: string): ExpiredLeaseRequeuePatch;
|
|
20
|
+
export declare function positiveInteger(value: number | string | null | undefined): number | undefined;
|
|
21
|
+
//# sourceMappingURL=lease.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lease.d.ts","sourceRoot":"","sources":["../src/lease.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,QAAS,CAAC;AACvC,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAE/C,MAAM,MAAM,cAAc,GACtB,WAAW,GACX,SAAS,GACT,WAAW,GACX,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,SAAS,CAAC;AAEd,MAAM,MAAM,wBAAwB,GAAG;IACrC,SAAS,EAAE,IAAI,CAAC;IAChB,WAAW,EAAE,IAAI,CAAC;IAClB,cAAc,EAAE,IAAI,CAAC;IACrB,aAAa,EAAE,IAAI,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,IAAI,CAAC;IAChB,QAAQ,EAAE,IAAI,CAAC;CAChB,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAQ9D;AAED,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,SAAmB,GAAG,IAAI,CAE1E;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,cAAc,EAAE,MAAM,GAAG,QAAQ,CAAC,CAE5C;AAED,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,IAAI,EACT,MAAM,SAAsD,GAC3D,wBAAwB,CAW1B;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GACxC,MAAM,GAAG,SAAS,CASpB"}
|
package/dist/lease.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export const DEFAULT_LEASE_MS = 60_000;
|
|
2
|
+
export const DEFAULT_RECONCILE_LIMIT = 100;
|
|
3
|
+
export const DEFAULT_CANDIDATE_SCAN_LIMIT = 25;
|
|
4
|
+
export function retryDelayMsForAttempt(attempt) {
|
|
5
|
+
if (attempt <= 1) {
|
|
6
|
+
return 10_000;
|
|
7
|
+
}
|
|
8
|
+
if (attempt === 2) {
|
|
9
|
+
return 60_000;
|
|
10
|
+
}
|
|
11
|
+
return 300_000;
|
|
12
|
+
}
|
|
13
|
+
export function retryDelayMsAfterFailedAttempt(attempt) {
|
|
14
|
+
return retryDelayMsForAttempt(attempt);
|
|
15
|
+
}
|
|
16
|
+
export function leaseExpiresAt(now, leaseMs = DEFAULT_LEASE_MS) {
|
|
17
|
+
return new Date(now.getTime() + leaseMs);
|
|
18
|
+
}
|
|
19
|
+
export function failedRunStatusForAttempt(attempt, maxAttempts) {
|
|
20
|
+
return attempt >= maxAttempts ? "dead" : "failed";
|
|
21
|
+
}
|
|
22
|
+
export function expiredLeaseRequeuePatch(now, reason = "Run lease expired; re-queued for worker recovery.") {
|
|
23
|
+
return {
|
|
24
|
+
claimedAt: null,
|
|
25
|
+
heartbeatAt: null,
|
|
26
|
+
leaseExpiresAt: null,
|
|
27
|
+
nextAttemptAt: now,
|
|
28
|
+
status: "queued",
|
|
29
|
+
statusReason: reason,
|
|
30
|
+
updatedAt: now,
|
|
31
|
+
workerId: null,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export function positiveInteger(value) {
|
|
35
|
+
if (value === undefined || value === null || value === "") {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
const parsed = Number(value);
|
|
39
|
+
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
return parsed;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=lease.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lease.js","sourceRoot":"","sources":["../src/lease.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AACvC,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,CAAC;AAsB/C,MAAM,UAAU,sBAAsB,CAAC,OAAe;IACpD,IAAI,OAAO,IAAI,CAAC,EAAE,CAAC;QACjB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IAAI,OAAO,KAAK,CAAC,EAAE,CAAC;QAClB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,OAAe;IAC5D,OAAO,sBAAsB,CAAC,OAAO,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAS,EAAE,OAAO,GAAG,gBAAgB;IAClE,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,OAAe,EACf,WAAmB;IAEnB,OAAO,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC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