@zudojs/scheduler 0.0.1
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/LICENSE +21 -0
- package/README.md +41 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/scheduler/clock/index.d.ts +3 -0
- package/dist/scheduler/clock/index.d.ts.map +1 -0
- package/dist/scheduler/clock/index.js +2 -0
- package/dist/scheduler/clock/index.js.map +1 -0
- package/dist/scheduler/clock/schedulerClock.type.d.ts +21 -0
- package/dist/scheduler/clock/schedulerClock.type.d.ts.map +1 -0
- package/dist/scheduler/clock/schedulerClock.type.js +18 -0
- package/dist/scheduler/clock/schedulerClock.type.js.map +1 -0
- package/dist/scheduler/constants/index.d.ts +2 -0
- package/dist/scheduler/constants/index.d.ts.map +1 -0
- package/dist/scheduler/constants/index.js +2 -0
- package/dist/scheduler/constants/index.js.map +1 -0
- package/dist/scheduler/constants/schedulerConstants.core.d.ts +52 -0
- package/dist/scheduler/constants/schedulerConstants.core.d.ts.map +1 -0
- package/dist/scheduler/constants/schedulerConstants.core.js +50 -0
- package/dist/scheduler/constants/schedulerConstants.core.js.map +1 -0
- package/dist/scheduler/duration/duration.parser.d.ts +11 -0
- package/dist/scheduler/duration/duration.parser.d.ts.map +1 -0
- package/dist/scheduler/duration/duration.parser.js +31 -0
- package/dist/scheduler/duration/duration.parser.js.map +1 -0
- package/dist/scheduler/duration/index.d.ts +2 -0
- package/dist/scheduler/duration/index.d.ts.map +1 -0
- package/dist/scheduler/duration/index.js +2 -0
- package/dist/scheduler/duration/index.js.map +1 -0
- package/dist/scheduler/errors/index.d.ts +3 -0
- package/dist/scheduler/errors/index.d.ts.map +1 -0
- package/dist/scheduler/errors/index.js +2 -0
- package/dist/scheduler/errors/index.js.map +1 -0
- package/dist/scheduler/errors/scheduler.errors.d.ts +10 -0
- package/dist/scheduler/errors/scheduler.errors.d.ts.map +1 -0
- package/dist/scheduler/errors/scheduler.errors.js +9 -0
- package/dist/scheduler/errors/scheduler.errors.js.map +1 -0
- package/dist/scheduler/executor/index.d.ts +2 -0
- package/dist/scheduler/executor/index.d.ts.map +1 -0
- package/dist/scheduler/executor/index.js +2 -0
- package/dist/scheduler/executor/index.js.map +1 -0
- package/dist/scheduler/executor/jobExecutor.core.d.ts +19 -0
- package/dist/scheduler/executor/jobExecutor.core.d.ts.map +1 -0
- package/dist/scheduler/executor/jobExecutor.core.js +50 -0
- package/dist/scheduler/executor/jobExecutor.core.js.map +1 -0
- package/dist/scheduler/job/index.d.ts +7 -0
- package/dist/scheduler/job/index.d.ts.map +1 -0
- package/dist/scheduler/job/index.js +3 -0
- package/dist/scheduler/job/index.js.map +1 -0
- package/dist/scheduler/job/jobContext.type.d.ts +17 -0
- package/dist/scheduler/job/jobContext.type.d.ts.map +1 -0
- package/dist/scheduler/job/jobContext.type.js +15 -0
- package/dist/scheduler/job/jobContext.type.js.map +1 -0
- package/dist/scheduler/job/jobDefinition.type.d.ts +16 -0
- package/dist/scheduler/job/jobDefinition.type.d.ts.map +1 -0
- package/dist/scheduler/job/jobDefinition.type.js +12 -0
- package/dist/scheduler/job/jobDefinition.type.js.map +1 -0
- package/dist/scheduler/job/jobHandler.type.d.ts +6 -0
- package/dist/scheduler/job/jobHandler.type.d.ts.map +1 -0
- package/dist/scheduler/job/jobHandler.type.js +2 -0
- package/dist/scheduler/job/jobHandler.type.js.map +1 -0
- package/dist/scheduler/job/jobOptions.type.d.ts +25 -0
- package/dist/scheduler/job/jobOptions.type.d.ts.map +1 -0
- package/dist/scheduler/job/jobOptions.type.js +2 -0
- package/dist/scheduler/job/jobOptions.type.js.map +1 -0
- package/dist/scheduler/priorityQueue/index.d.ts +2 -0
- package/dist/scheduler/priorityQueue/index.d.ts.map +1 -0
- package/dist/scheduler/priorityQueue/index.js +2 -0
- package/dist/scheduler/priorityQueue/index.js.map +1 -0
- package/dist/scheduler/priorityQueue/schedulerPriorityQueue.core.d.ts +46 -0
- package/dist/scheduler/priorityQueue/schedulerPriorityQueue.core.d.ts.map +1 -0
- package/dist/scheduler/priorityQueue/schedulerPriorityQueue.core.js +121 -0
- package/dist/scheduler/priorityQueue/schedulerPriorityQueue.core.js.map +1 -0
- package/dist/scheduler/registry/index.d.ts +2 -0
- package/dist/scheduler/registry/index.d.ts.map +1 -0
- package/dist/scheduler/registry/index.js +2 -0
- package/dist/scheduler/registry/index.js.map +1 -0
- package/dist/scheduler/registry/jobRegistry.core.d.ts +32 -0
- package/dist/scheduler/registry/jobRegistry.core.d.ts.map +1 -0
- package/dist/scheduler/registry/jobRegistry.core.js +52 -0
- package/dist/scheduler/registry/jobRegistry.core.js.map +1 -0
- package/dist/scheduler/schedule/index.d.ts +4 -0
- package/dist/scheduler/schedule/index.d.ts.map +1 -0
- package/dist/scheduler/schedule/index.js +2 -0
- package/dist/scheduler/schedule/index.js.map +1 -0
- package/dist/scheduler/schedule/schedule.type.d.ts +24 -0
- package/dist/scheduler/schedule/schedule.type.d.ts.map +1 -0
- package/dist/scheduler/schedule/schedule.type.js +14 -0
- package/dist/scheduler/schedule/schedule.type.js.map +1 -0
- package/dist/scheduler/schedule/scheduleOptions.type.d.ts +10 -0
- package/dist/scheduler/schedule/scheduleOptions.type.d.ts.map +1 -0
- package/dist/scheduler/schedule/scheduleOptions.type.js +2 -0
- package/dist/scheduler/schedule/scheduleOptions.type.js.map +1 -0
- package/dist/scheduler/scheduleHandle/index.d.ts +3 -0
- package/dist/scheduler/scheduleHandle/index.d.ts.map +1 -0
- package/dist/scheduler/scheduleHandle/index.js +2 -0
- package/dist/scheduler/scheduleHandle/index.js.map +1 -0
- package/dist/scheduler/scheduleHandle/scheduleHandle.type.d.ts +26 -0
- package/dist/scheduler/scheduleHandle/scheduleHandle.type.d.ts.map +1 -0
- package/dist/scheduler/scheduleHandle/scheduleHandle.type.js +29 -0
- package/dist/scheduler/scheduleHandle/scheduleHandle.type.js.map +1 -0
- package/dist/scheduler/scheduler.core.d.ts +64 -0
- package/dist/scheduler/scheduler.core.d.ts.map +1 -0
- package/dist/scheduler/scheduler.core.js +164 -0
- package/dist/scheduler/scheduler.core.js.map +1 -0
- package/dist/scheduler/trigger/index.d.ts +3 -0
- package/dist/scheduler/trigger/index.d.ts.map +1 -0
- package/dist/scheduler/trigger/index.js +2 -0
- package/dist/scheduler/trigger/index.js.map +1 -0
- package/dist/scheduler/trigger/schedulerTrigger.core.d.ts +35 -0
- package/dist/scheduler/trigger/schedulerTrigger.core.d.ts.map +1 -0
- package/dist/scheduler/trigger/schedulerTrigger.core.js +54 -0
- package/dist/scheduler/trigger/schedulerTrigger.core.js.map +1 -0
- package/dist/scheduler/trigger/trigger.type.d.ts +12 -0
- package/dist/scheduler/trigger/trigger.type.d.ts.map +1 -0
- package/dist/scheduler/trigger/trigger.type.js +7 -0
- package/dist/scheduler/trigger/trigger.type.js.map +1 -0
- package/dist/scheduler/types/index.d.ts +2 -0
- package/dist/scheduler/types/index.d.ts.map +1 -0
- package/dist/scheduler/types/index.js +2 -0
- package/dist/scheduler/types/index.js.map +1 -0
- package/dist/scheduler/types/schedulerTypes.core.d.ts +146 -0
- package/dist/scheduler/types/schedulerTypes.core.d.ts.map +1 -0
- package/dist/scheduler/types/schedulerTypes.core.js +7 -0
- package/dist/scheduler/types/schedulerTypes.core.js.map +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clock abstraction for time operations.
|
|
3
|
+
*
|
|
4
|
+
* Allows deterministic testing and clock manipulation.
|
|
5
|
+
*/
|
|
6
|
+
export interface Clock {
|
|
7
|
+
now(): Date;
|
|
8
|
+
nowMs(): number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* System clock that uses the actual system time.
|
|
12
|
+
*/
|
|
13
|
+
export declare class SystemClock implements Clock {
|
|
14
|
+
now(): Date;
|
|
15
|
+
nowMs(): number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new system clock.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createSystemClock(): SystemClock;
|
|
21
|
+
//# sourceMappingURL=schedulerClock.type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedulerClock.type.d.ts","sourceRoot":"","sources":["../../../src/scheduler/clock/schedulerClock.type.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,KAAK;IACpB,GAAG,IAAI,IAAI,CAAC;IAEZ,KAAK,IAAI,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,qBAAa,WAAY,YAAW,KAAK;IACvC,GAAG,IAAI,IAAI,CAEV;IAED,KAAK,IAAI,MAAM,CAEd;CACF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,CAE/C"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System clock that uses the actual system time.
|
|
3
|
+
*/
|
|
4
|
+
export class SystemClock {
|
|
5
|
+
now() {
|
|
6
|
+
return new Date();
|
|
7
|
+
}
|
|
8
|
+
nowMs() {
|
|
9
|
+
return Date.now();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new system clock.
|
|
14
|
+
*/
|
|
15
|
+
export function createSystemClock() {
|
|
16
|
+
return new SystemClock();
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=schedulerClock.type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedulerClock.type.js","sourceRoot":"","sources":["../../../src/scheduler/clock/schedulerClock.type.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,MAAM,OAAO,WAAW;IACtB,GAAG;QACD,OAAO,IAAI,IAAI,EAAE,CAAC;IACpB,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;IACpB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,IAAI,WAAW,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { DEFAULT_JOB_TIMEOUT, DEFAULT_MAX_CONCURRENCY, DEFAULT_MAX_RETRIES, DEFAULT_RETRY_DELAY, MAX_TIMER_DELAY, MAX_JOBS, MAX_SCHEDULES, MAX_EXECUTION_HISTORY, DEFAULT_MISFIRE_POLICY, DEFAULT_OVERLAP_POLICY, SCHEDULER_TICK_INTERVAL, } from "./schedulerConstants.core.js";
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/scheduler/constants/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,QAAQ,EACR,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { DEFAULT_JOB_TIMEOUT, DEFAULT_MAX_CONCURRENCY, DEFAULT_MAX_RETRIES, DEFAULT_RETRY_DELAY, MAX_TIMER_DELAY, MAX_JOBS, MAX_SCHEDULES, MAX_EXECUTION_HISTORY, DEFAULT_MISFIRE_POLICY, DEFAULT_OVERLAP_POLICY, SCHEDULER_TICK_INTERVAL, } from "./schedulerConstants.core.js";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scheduler/constants/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,QAAQ,EACR,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { MisfirePolicy } from "../types/schedulerTypes.core.js";
|
|
2
|
+
import type { OverlapPolicy } from "../types/schedulerTypes.core.js";
|
|
3
|
+
/**
|
|
4
|
+
* @zudojs/scheduler/constants
|
|
5
|
+
*
|
|
6
|
+
* Shared constants for the scheduler package.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Default timeout for job executions (30 seconds).
|
|
10
|
+
*/
|
|
11
|
+
export declare const DEFAULT_JOB_TIMEOUT = 30000;
|
|
12
|
+
/**
|
|
13
|
+
* Maximum number of concurrent job executions.
|
|
14
|
+
*/
|
|
15
|
+
export declare const DEFAULT_MAX_CONCURRENCY = 10;
|
|
16
|
+
/**
|
|
17
|
+
* Maximum number of retries for failed jobs.
|
|
18
|
+
*/
|
|
19
|
+
export declare const DEFAULT_MAX_RETRIES = 3;
|
|
20
|
+
/**
|
|
21
|
+
* Default retry delay in milliseconds.
|
|
22
|
+
*/
|
|
23
|
+
export declare const DEFAULT_RETRY_DELAY = 1000;
|
|
24
|
+
/**
|
|
25
|
+
* Maximum timer delay in milliseconds (to avoid timer drift issues).
|
|
26
|
+
*/
|
|
27
|
+
export declare const MAX_TIMER_DELAY = 2147483647;
|
|
28
|
+
/**
|
|
29
|
+
* Maximum number of jobs allowed in the registry.
|
|
30
|
+
*/
|
|
31
|
+
export declare const MAX_JOBS = 4096;
|
|
32
|
+
/**
|
|
33
|
+
* Maximum number of schedules allowed.
|
|
34
|
+
*/
|
|
35
|
+
export declare const MAX_SCHEDULES = 4096;
|
|
36
|
+
/**
|
|
37
|
+
* Maximum execution history to keep in memory per job.
|
|
38
|
+
*/
|
|
39
|
+
export declare const MAX_EXECUTION_HISTORY = 100;
|
|
40
|
+
/**
|
|
41
|
+
* Default misfire policy.
|
|
42
|
+
*/
|
|
43
|
+
export declare const DEFAULT_MISFIRE_POLICY: MisfirePolicy;
|
|
44
|
+
/**
|
|
45
|
+
* Default overlap policy.
|
|
46
|
+
*/
|
|
47
|
+
export declare const DEFAULT_OVERLAP_POLICY: OverlapPolicy;
|
|
48
|
+
/**
|
|
49
|
+
* Tick interval for the scheduler timer (1 second).
|
|
50
|
+
*/
|
|
51
|
+
export declare const SCHEDULER_TICK_INTERVAL = 1000;
|
|
52
|
+
//# sourceMappingURL=schedulerConstants.core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedulerConstants.core.d.ts","sourceRoot":"","sources":["../../../src/scheduler/constants/schedulerConstants.core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAErE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAErE;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,mBAAmB,QAAS,CAAC;AAE1C;;GAEG;AACH,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C;;GAEG;AACH,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,mBAAmB,OAAQ,CAAC;AAEzC;;GAEG;AACH,eAAO,MAAM,eAAe,aAAgB,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,QAAQ,OAAO,CAAC;AAE7B;;GAEG;AACH,eAAO,MAAM,aAAa,OAAO,CAAC;AAElC;;GAEG;AACH,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,aAA0B,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,aAAuB,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,uBAAuB,OAAQ,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @zudojs/scheduler/constants
|
|
3
|
+
*
|
|
4
|
+
* Shared constants for the scheduler package.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Default timeout for job executions (30 seconds).
|
|
8
|
+
*/
|
|
9
|
+
export const DEFAULT_JOB_TIMEOUT = 30_000;
|
|
10
|
+
/**
|
|
11
|
+
* Maximum number of concurrent job executions.
|
|
12
|
+
*/
|
|
13
|
+
export const DEFAULT_MAX_CONCURRENCY = 10;
|
|
14
|
+
/**
|
|
15
|
+
* Maximum number of retries for failed jobs.
|
|
16
|
+
*/
|
|
17
|
+
export const DEFAULT_MAX_RETRIES = 3;
|
|
18
|
+
/**
|
|
19
|
+
* Default retry delay in milliseconds.
|
|
20
|
+
*/
|
|
21
|
+
export const DEFAULT_RETRY_DELAY = 1_000;
|
|
22
|
+
/**
|
|
23
|
+
* Maximum timer delay in milliseconds (to avoid timer drift issues).
|
|
24
|
+
*/
|
|
25
|
+
export const MAX_TIMER_DELAY = 2_147_483_647;
|
|
26
|
+
/**
|
|
27
|
+
* Maximum number of jobs allowed in the registry.
|
|
28
|
+
*/
|
|
29
|
+
export const MAX_JOBS = 4096;
|
|
30
|
+
/**
|
|
31
|
+
* Maximum number of schedules allowed.
|
|
32
|
+
*/
|
|
33
|
+
export const MAX_SCHEDULES = 4096;
|
|
34
|
+
/**
|
|
35
|
+
* Maximum execution history to keep in memory per job.
|
|
36
|
+
*/
|
|
37
|
+
export const MAX_EXECUTION_HISTORY = 100;
|
|
38
|
+
/**
|
|
39
|
+
* Default misfire policy.
|
|
40
|
+
*/
|
|
41
|
+
export const DEFAULT_MISFIRE_POLICY = "run-once";
|
|
42
|
+
/**
|
|
43
|
+
* Default overlap policy.
|
|
44
|
+
*/
|
|
45
|
+
export const DEFAULT_OVERLAP_POLICY = "allow";
|
|
46
|
+
/**
|
|
47
|
+
* Tick interval for the scheduler timer (1 second).
|
|
48
|
+
*/
|
|
49
|
+
export const SCHEDULER_TICK_INTERVAL = 1_000;
|
|
50
|
+
//# sourceMappingURL=schedulerConstants.core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedulerConstants.core.js","sourceRoot":"","sources":["../../../src/scheduler/constants/schedulerConstants.core.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAErC;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC;AAE7B;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAkB,UAAU,CAAC;AAEhE;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAkB,OAAO,CAAC;AAE7D;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses a human-readable duration string into milliseconds.
|
|
3
|
+
*
|
|
4
|
+
* Supported formats:
|
|
5
|
+
* - "5s" - 5 seconds
|
|
6
|
+
* - "10m" - 10 minutes
|
|
7
|
+
* - "2h" - 2 hours
|
|
8
|
+
* - "3d" - 3 days
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseDuration(duration: string): number;
|
|
11
|
+
//# sourceMappingURL=duration.parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duration.parser.d.ts","sourceRoot":"","sources":["../../../src/scheduler/duration/duration.parser.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAqBtD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { InvalidDurationError } from "../errors/scheduler.errors.js";
|
|
2
|
+
/**
|
|
3
|
+
* Parses a human-readable duration string into milliseconds.
|
|
4
|
+
*
|
|
5
|
+
* Supported formats:
|
|
6
|
+
* - "5s" - 5 seconds
|
|
7
|
+
* - "10m" - 10 minutes
|
|
8
|
+
* - "2h" - 2 hours
|
|
9
|
+
* - "3d" - 3 days
|
|
10
|
+
*/
|
|
11
|
+
export function parseDuration(duration) {
|
|
12
|
+
const match = duration.match(/^(\d+)(s|m|h|d)$/);
|
|
13
|
+
if (!match) {
|
|
14
|
+
throw new InvalidDurationError(duration);
|
|
15
|
+
}
|
|
16
|
+
const value = Number(match[1]);
|
|
17
|
+
const unit = match[2];
|
|
18
|
+
switch (unit) {
|
|
19
|
+
case "s":
|
|
20
|
+
return value * 1000;
|
|
21
|
+
case "m":
|
|
22
|
+
return value * 60 * 1000;
|
|
23
|
+
case "h":
|
|
24
|
+
return value * 60 * 60 * 1000;
|
|
25
|
+
case "d":
|
|
26
|
+
return value * 24 * 60 * 60 * 1000;
|
|
27
|
+
default:
|
|
28
|
+
throw new InvalidDurationError(duration);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=duration.parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duration.parser.js","sourceRoot":"","sources":["../../../src/scheduler/duration/duration.parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACjD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAEtB,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,GAAG;YACN,OAAO,KAAK,GAAG,IAAI,CAAC;QACtB,KAAK,GAAG;YACN,OAAO,KAAK,GAAG,EAAE,GAAG,IAAI,CAAC;QAC3B,KAAK,GAAG;YACN,OAAO,KAAK,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QAChC,KAAK,GAAG;YACN,OAAO,KAAK,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QACrC;YACE,MAAM,IAAI,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/scheduler/duration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scheduler/duration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { SchedulerError, SchedulerNotStartedError, SchedulerAlreadyStartedError, SchedulerStoppedError, SchedulerJobNotFoundError, SchedulerJobAlreadyExistsError, InvalidJobError, ScheduleNotFoundError, ScheduleAlreadyExistsError, InvalidScheduleError, CronParseError, InvalidDurationError, SchedulerJobExecutionError, SchedulerJobTimeoutError, SchedulerJobCancelledError, SchedulerStoreError, SchedulerLockError, createSchedulerError, isSchedulerError, } from "./scheduler.errors.js";
|
|
2
|
+
export type { SchedulerErrorOptions } from "./scheduler.errors.js";
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/scheduler/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,4BAA4B,EAC5B,qBAAqB,EACrB,yBAAyB,EACzB,8BAA8B,EAC9B,eAAe,EACf,qBAAqB,EACrB,0BAA0B,EAC1B,oBAAoB,EACpB,cAAc,EACd,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { SchedulerError, SchedulerNotStartedError, SchedulerAlreadyStartedError, SchedulerStoppedError, SchedulerJobNotFoundError, SchedulerJobAlreadyExistsError, InvalidJobError, ScheduleNotFoundError, ScheduleAlreadyExistsError, InvalidScheduleError, CronParseError, InvalidDurationError, SchedulerJobExecutionError, SchedulerJobTimeoutError, SchedulerJobCancelledError, SchedulerStoreError, SchedulerLockError, createSchedulerError, isSchedulerError, } from "./scheduler.errors.js";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scheduler/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,4BAA4B,EAC5B,qBAAqB,EACrB,yBAAyB,EACzB,8BAA8B,EAC9B,eAAe,EACf,qBAAqB,EACrB,0BAA0B,EAC1B,oBAAoB,EACpB,cAAc,EACd,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @zudojs/scheduler/errors
|
|
3
|
+
*
|
|
4
|
+
* Scheduler-specific error classes for the Zudojs framework.
|
|
5
|
+
*
|
|
6
|
+
* Re-exported from @zudojs/errors for convenience.
|
|
7
|
+
*/
|
|
8
|
+
export { SchedulerError, SchedulerNotStartedError, SchedulerAlreadyStartedError, SchedulerStoppedError, SchedulerJobNotFoundError, SchedulerJobAlreadyExistsError, InvalidJobError, ScheduleNotFoundError, ScheduleAlreadyExistsError, InvalidScheduleError, CronParseError, InvalidDurationError, SchedulerJobExecutionError, SchedulerJobTimeoutError, SchedulerJobCancelledError, SchedulerStoreError, SchedulerLockError, createSchedulerError, isSchedulerError, } from "@zudojs/errors";
|
|
9
|
+
export type { SchedulerErrorOptions } from "@zudojs/errors";
|
|
10
|
+
//# sourceMappingURL=scheduler.errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler.errors.d.ts","sourceRoot":"","sources":["../../../src/scheduler/errors/scheduler.errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,4BAA4B,EAC5B,qBAAqB,EACrB,yBAAyB,EACzB,8BAA8B,EAC9B,eAAe,EACf,qBAAqB,EACrB,0BAA0B,EAC1B,oBAAoB,EACpB,cAAc,EACd,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @zudojs/scheduler/errors
|
|
3
|
+
*
|
|
4
|
+
* Scheduler-specific error classes for the Zudojs framework.
|
|
5
|
+
*
|
|
6
|
+
* Re-exported from @zudojs/errors for convenience.
|
|
7
|
+
*/
|
|
8
|
+
export { SchedulerError, SchedulerNotStartedError, SchedulerAlreadyStartedError, SchedulerStoppedError, SchedulerJobNotFoundError, SchedulerJobAlreadyExistsError, InvalidJobError, ScheduleNotFoundError, ScheduleAlreadyExistsError, InvalidScheduleError, CronParseError, InvalidDurationError, SchedulerJobExecutionError, SchedulerJobTimeoutError, SchedulerJobCancelledError, SchedulerStoreError, SchedulerLockError, createSchedulerError, isSchedulerError, } from "@zudojs/errors";
|
|
9
|
+
//# sourceMappingURL=scheduler.errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler.errors.js","sourceRoot":"","sources":["../../../src/scheduler/errors/scheduler.errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,4BAA4B,EAC5B,qBAAqB,EACrB,yBAAyB,EACzB,8BAA8B,EAC9B,eAAe,EACf,qBAAqB,EACrB,0BAA0B,EAC1B,oBAAoB,EACpB,cAAc,EACd,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/scheduler/executor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scheduler/executor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { JobDefinition } from "../job/jobDefinition.type.js";
|
|
2
|
+
import type { JobExecutionResult } from "../types/schedulerTypes.core.js";
|
|
3
|
+
import type { Clock } from "../clock/schedulerClock.type.js";
|
|
4
|
+
/**
|
|
5
|
+
* Executes a job with timeout support.
|
|
6
|
+
*/
|
|
7
|
+
export declare class JobExecutor {
|
|
8
|
+
private readonly clock;
|
|
9
|
+
constructor(clock: Clock);
|
|
10
|
+
/**
|
|
11
|
+
* Executes a job.
|
|
12
|
+
*/
|
|
13
|
+
execute(job: JobDefinition, executionId: string, scheduledAt: Date, attempt: number, signal: AbortSignal): Promise<JobExecutionResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Wraps a promise with a timeout using AbortSignal.
|
|
16
|
+
*/
|
|
17
|
+
private withTimeout;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=jobExecutor.core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobExecutor.core.d.ts","sourceRoot":"","sources":["../../../src/scheduler/executor/jobExecutor.core.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAW7D;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAE9B,YAAY,KAAK,EAAE,KAAK,EAEvB;IAED;;OAEG;IACG,OAAO,CACX,GAAG,EAAE,aAAa,EAClB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,IAAI,EACjB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,kBAAkB,CAAC,CAgC7B;IAED;;OAEG;YACW,WAAW;CAsB1B"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createJobContext } from "../job/jobContext.type.js";
|
|
2
|
+
import { SchedulerJobExecutionError, SchedulerJobCancelledError, } from "../errors/scheduler.errors.js";
|
|
3
|
+
import { DEFAULT_JOB_TIMEOUT } from "../constants/schedulerConstants.core.js";
|
|
4
|
+
/**
|
|
5
|
+
* Executes a job with timeout support.
|
|
6
|
+
*/
|
|
7
|
+
export class JobExecutor {
|
|
8
|
+
clock;
|
|
9
|
+
constructor(clock) {
|
|
10
|
+
this.clock = clock;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Executes a job.
|
|
14
|
+
*/
|
|
15
|
+
async execute(job, executionId, scheduledAt, attempt, signal) {
|
|
16
|
+
const timeout = job.options?.timeout ?? DEFAULT_JOB_TIMEOUT;
|
|
17
|
+
const context = createJobContext(job.id, executionId, scheduledAt, this.clock.now(), attempt, undefined, signal);
|
|
18
|
+
try {
|
|
19
|
+
await this.withTimeout(() => Promise.resolve(job.handler(context)), timeout, signal);
|
|
20
|
+
return { success: true };
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
if (signal.aborted) {
|
|
24
|
+
throw new SchedulerJobCancelledError("Job was cancelled via signal.", job.id);
|
|
25
|
+
}
|
|
26
|
+
throw new SchedulerJobExecutionError(error instanceof Error ? error.message : "Unknown job execution error.", job.id);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Wraps a promise with a timeout using AbortSignal.
|
|
31
|
+
*/
|
|
32
|
+
async withTimeout(operation, timeout, signal) {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
const timer = setTimeout(() => {
|
|
35
|
+
reject(new Error(`Job timed out after ${timeout}ms.`));
|
|
36
|
+
}, timeout);
|
|
37
|
+
Promise.resolve()
|
|
38
|
+
.then(() => Promise.resolve(operation()))
|
|
39
|
+
.then((result) => {
|
|
40
|
+
clearTimeout(timer);
|
|
41
|
+
resolve(result);
|
|
42
|
+
})
|
|
43
|
+
.catch((error) => {
|
|
44
|
+
clearTimeout(timer);
|
|
45
|
+
reject(error);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=jobExecutor.core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobExecutor.core.js","sourceRoot":"","sources":["../../../src/scheduler/executor/jobExecutor.core.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAE9E;;GAEG;AACH,MAAM,OAAO,WAAW;IACL,KAAK,CAAQ;IAE9B,YAAY,KAAY;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO,CACX,GAAkB,EAClB,WAAmB,EACnB,WAAiB,EACjB,OAAe,EACf,MAAmB;QAEnB,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,OAAO,IAAI,mBAAmB,CAAC;QAE5D,MAAM,OAAO,GAAG,gBAAgB,CAC9B,GAAG,CAAC,EAAE,EACN,WAAW,EACX,WAAW,EACX,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,EAChB,OAAO,EACP,SAAS,EACT,MAAM,CACP,CAAC;QAEF,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,WAAW,CACpB,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAC3C,OAAO,EACP,MAAM,CACP,CAAC;YACF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,MAAM,IAAI,0BAA0B,CAClC,+BAA+B,EAC/B,GAAG,CAAC,EAAE,CACP,CAAC;YACJ,CAAC;YACD,MAAM,IAAI,0BAA0B,CAClC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,8BAA8B,EACvE,GAAG,CAAC,EAAE,CACP,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,WAAW,CACvB,SAA2B,EAC3B,OAAe,EACf,MAAmB;QAEnB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;gBAC5B,MAAM,CAAC,IAAI,KAAK,CAAC,uBAAuB,OAAO,KAAK,CAAC,CAAC,CAAC;YACzD,CAAC,EAAE,OAAO,CAAC,CAAC;YAEZ,OAAO,CAAC,OAAO,EAAE;iBACd,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;iBACxC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;gBACf,YAAY,CAAC,KAAK,CAAC,CAAC;gBACpB,OAAO,CAAC,MAAM,CAAC,CAAC;YAClB,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBACf,YAAY,CAAC,KAAK,CAAC,CAAC;gBACpB,MAAM,CAAC,KAAK,CAAC,CAAC;YAChB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { JobHandler } from "./jobHandler.type.js";
|
|
2
|
+
export type { JobContext } from "./jobContext.type.js";
|
|
3
|
+
export { createJobContext } from "./jobContext.type.js";
|
|
4
|
+
export type { JobDefinition } from "./jobDefinition.type.js";
|
|
5
|
+
export { createJobDefinition } from "./jobDefinition.type.js";
|
|
6
|
+
export type { JobOptions, RetryPolicy, RetryStrategy, } from "./jobOptions.type.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/scheduler/job/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,YAAY,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,YAAY,EACV,UAAU,EACV,WAAW,EACX,aAAa,GACd,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scheduler/job/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAIxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context passed to a job handler during execution.
|
|
3
|
+
*/
|
|
4
|
+
export interface JobContext<T = unknown> {
|
|
5
|
+
readonly jobId: string;
|
|
6
|
+
readonly executionId: string;
|
|
7
|
+
readonly scheduledAt: Date;
|
|
8
|
+
readonly startedAt: Date;
|
|
9
|
+
readonly attempt: number;
|
|
10
|
+
readonly data: T;
|
|
11
|
+
readonly signal: AbortSignal;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Creates a job context.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createJobContext<T = unknown>(jobId: string, executionId: string, scheduledAt: Date, startedAt: Date, attempt: number, data: T, signal: AbortSignal): JobContext<T>;
|
|
17
|
+
//# sourceMappingURL=jobContext.type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobContext.type.d.ts","sourceRoot":"","sources":["../../../src/scheduler/job/jobContext.type.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,GAAG,OAAO;IACrC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC;IAE3B,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IAEzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAEjB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,OAAO,EAC1C,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,IAAI,EACjB,SAAS,EAAE,IAAI,EACf,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,WAAW,GAClB,UAAU,CAAC,CAAC,CAAC,CAUf"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a job context.
|
|
3
|
+
*/
|
|
4
|
+
export function createJobContext(jobId, executionId, scheduledAt, startedAt, attempt, data, signal) {
|
|
5
|
+
return Object.freeze({
|
|
6
|
+
jobId,
|
|
7
|
+
executionId,
|
|
8
|
+
scheduledAt,
|
|
9
|
+
startedAt,
|
|
10
|
+
attempt,
|
|
11
|
+
data,
|
|
12
|
+
signal,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=jobContext.type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobContext.type.js","sourceRoot":"","sources":["../../../src/scheduler/job/jobContext.type.ts"],"names":[],"mappings":"AAmBA;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAa,EACb,WAAmB,EACnB,WAAiB,EACjB,SAAe,EACf,OAAe,EACf,IAAO,EACP,MAAmB;IAEnB,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,KAAK;QACL,WAAW;QACX,WAAW;QACX,SAAS;QACT,OAAO;QACP,IAAI;QACJ,MAAM;KACP,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { JobHandler } from "./jobHandler.type.js";
|
|
2
|
+
import type { JobOptions } from "./jobOptions.type.js";
|
|
3
|
+
/**
|
|
4
|
+
* Definition of a scheduled job.
|
|
5
|
+
*/
|
|
6
|
+
export interface JobDefinition {
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly handler: JobHandler;
|
|
10
|
+
readonly options?: JobOptions;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Creates a job definition.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createJobDefinition(id: string, name: string, handler: JobHandler, options?: JobOptions): JobDefinition;
|
|
16
|
+
//# sourceMappingURL=jobDefinition.type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobDefinition.type.d.ts","sourceRoot":"","sources":["../../../src/scheduler/job/jobDefinition.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAE7B,QAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC;CAC/B;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,UAAU,EACnB,OAAO,GAAE,UAAe,GACvB,aAAa,CAOf"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a job definition.
|
|
3
|
+
*/
|
|
4
|
+
export function createJobDefinition(id, name, handler, options = {}) {
|
|
5
|
+
return Object.freeze({
|
|
6
|
+
id,
|
|
7
|
+
name,
|
|
8
|
+
handler,
|
|
9
|
+
options: Object.freeze(options),
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=jobDefinition.type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobDefinition.type.js","sourceRoot":"","sources":["../../../src/scheduler/job/jobDefinition.type.ts"],"names":[],"mappings":"AAiBA;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,EAAU,EACV,IAAY,EACZ,OAAmB,EACnB,OAAO,GAAe,EAAE;IAExB,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,EAAE;QACF,IAAI;QACJ,OAAO;QACP,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;KAChC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobHandler.type.d.ts","sourceRoot":"","sources":["../../../src/scheduler/job/jobHandler.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,GAAG,OAAO,IAAI,CACpC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,KACnB,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobHandler.type.js","sourceRoot":"","sources":["../../../src/scheduler/job/jobHandler.type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { OverlapPolicy } from "../types/schedulerTypes.core.js";
|
|
2
|
+
/**
|
|
3
|
+
* Options for a scheduled job.
|
|
4
|
+
*/
|
|
5
|
+
export interface JobOptions {
|
|
6
|
+
readonly timeout?: number;
|
|
7
|
+
readonly retry?: RetryPolicy;
|
|
8
|
+
readonly concurrency?: number;
|
|
9
|
+
readonly overlap?: OverlapPolicy;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Retry policy for job executions.
|
|
13
|
+
*/
|
|
14
|
+
export interface RetryPolicy {
|
|
15
|
+
readonly attempts: number;
|
|
16
|
+
readonly strategy: RetryStrategy;
|
|
17
|
+
readonly delay: number;
|
|
18
|
+
readonly maxDelay?: number;
|
|
19
|
+
readonly jitter?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Retry strategy.
|
|
23
|
+
*/
|
|
24
|
+
export type RetryStrategy = "fixed" | "linear" | "exponential";
|
|
25
|
+
//# sourceMappingURL=jobOptions.type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobOptions.type.d.ts","sourceRoot":"","sources":["../../../src/scheduler/job/jobOptions.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAE1B,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAE7B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IAEjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAE3B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,QAAQ,GAAG,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobOptions.type.js","sourceRoot":"","sources":["../../../src/scheduler/job/jobOptions.type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/scheduler/priorityQueue/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scheduler/priorityQueue/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Schedule } from "../schedule/schedule.type.js";
|
|
2
|
+
/**
|
|
3
|
+
* Priority queue using a min heap for scheduling.
|
|
4
|
+
*
|
|
5
|
+
* Provides O(log n) insertion and removal, and O(1) peek.
|
|
6
|
+
*/
|
|
7
|
+
export declare class PriorityQueue {
|
|
8
|
+
private readonly heap;
|
|
9
|
+
/**
|
|
10
|
+
* Inserts a schedule into the priority queue.
|
|
11
|
+
*/
|
|
12
|
+
enqueue(schedule: Schedule): void;
|
|
13
|
+
/**
|
|
14
|
+
* Removes and returns the earliest schedule.
|
|
15
|
+
*/
|
|
16
|
+
dequeue(): Schedule | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the earliest schedule without removing it.
|
|
19
|
+
*/
|
|
20
|
+
peek(): Schedule | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Removes a schedule by ID.
|
|
23
|
+
*/
|
|
24
|
+
remove(id: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the number of schedules in the queue.
|
|
27
|
+
*/
|
|
28
|
+
get size(): number;
|
|
29
|
+
/**
|
|
30
|
+
* Determines whether the queue is empty.
|
|
31
|
+
*/
|
|
32
|
+
get isEmpty(): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Clears all schedules from the queue.
|
|
35
|
+
*/
|
|
36
|
+
clear(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Bubble up an element to maintain heap property.
|
|
39
|
+
*/
|
|
40
|
+
private bubbleUp;
|
|
41
|
+
/**
|
|
42
|
+
* Sink down an element to maintain heap property.
|
|
43
|
+
*/
|
|
44
|
+
private sinkDown;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=schedulerPriorityQueue.core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedulerPriorityQueue.core.d.ts","sourceRoot":"","sources":["../../../src/scheduler/priorityQueue/schedulerPriorityQueue.core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAE7D;;;;GAIG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAkB;IAEvC;;OAEG;IACH,OAAO,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAGhC;IAED;;OAEG;IACH,OAAO,IAAI,QAAQ,GAAG,SAAS,CAc9B;IAED;;OAEG;IACH,IAAI,IAAI,QAAQ,GAAG,SAAS,CAK3B;IAED;;OAEG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAe1B;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB;IAED;;OAEG;IACH,KAAK,IAAI,IAAI,CAEZ;IAED;;OAEG;IACH,OAAO,CAAC,QAAQ;IAehB;;OAEG;IACH,OAAO,CAAC,QAAQ;CAiCjB"}
|