@orion-js/dogs 4.6.6 → 4.6.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/index.cjs +161 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +161 -24
- package/dist/index.js.map +1 -1
- package/dist/repos/JobsRepo.d.ts +1 -0
- package/dist/services/Executor.d.ts +6 -0
- package/dist/types/StartConfig.d.ts +18 -0
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Blackbox } from '@orion-js/schema';
|
|
2
2
|
import { EventJobDefinition, JobDefinition, JobsDefinition } from '../types/JobsDefinition';
|
|
3
|
+
import { WorkerExecutionGuard, WorkerExecutionGuardLease } from '../types/StartConfig';
|
|
3
4
|
import { ExecutionContext, JobToRun } from '../types/Worker';
|
|
4
5
|
/**
|
|
5
6
|
* Configuration for job execution including max tries settings.
|
|
@@ -9,6 +10,8 @@ export interface ExecuteJobConfig {
|
|
|
9
10
|
maxTries?: number;
|
|
10
11
|
maxTriesReachedRetentionMs?: number | null;
|
|
11
12
|
onMaxTriesReached?: (job: JobToRun) => Promise<void>;
|
|
13
|
+
executionGuard?: WorkerExecutionGuard;
|
|
14
|
+
executionGuardRetryDelayMs?: number;
|
|
12
15
|
}
|
|
13
16
|
export declare class Executor {
|
|
14
17
|
private readonly jobsRepo;
|
|
@@ -40,5 +43,8 @@ export declare class Executor {
|
|
|
40
43
|
jobToRun: JobToRun;
|
|
41
44
|
}): Promise<void>;
|
|
42
45
|
afterExecutionSuccess(job: JobDefinition, jobToRun: JobToRun, context: ExecutionContext): Promise<boolean>;
|
|
46
|
+
handleExecutionGuardAcquisitionFailure(error: unknown, config: ExecuteJobConfig, jobToRun: JobToRun, context: ExecutionContext): Promise<void>;
|
|
47
|
+
releaseExecutionGuardLease(lease: WorkerExecutionGuardLease, jobToRun: JobToRun, context: ExecutionContext): Promise<void>;
|
|
48
|
+
runGuardedResolver(job: JobDefinition, jobToRun: JobToRun, context: ExecutionContext, lease: WorkerExecutionGuardLease): Promise<any>;
|
|
43
49
|
executeJob(config: ExecuteJobConfig, jobToRun: JobToRun, onExecutionStale: () => void): Promise<void>;
|
|
44
50
|
}
|
|
@@ -2,6 +2,18 @@ import { JobsDefinition } from './JobsDefinition';
|
|
|
2
2
|
import { JobToRun } from './Worker';
|
|
3
3
|
export type LogLevels = 'debug' | 'info' | 'warn' | 'error' | 'none';
|
|
4
4
|
export declare const DEFAULT_MAX_TRIES_REACHED_RETENTION_MS: number;
|
|
5
|
+
/**
|
|
6
|
+
* A lease held for the duration of one job resolver execution.
|
|
7
|
+
*/
|
|
8
|
+
export interface WorkerExecutionGuardLease {
|
|
9
|
+
release(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Acquires infrastructure protection for a claimed job before its resolver starts.
|
|
13
|
+
*/
|
|
14
|
+
export interface WorkerExecutionGuard {
|
|
15
|
+
acquire(job: JobToRun): Promise<WorkerExecutionGuardLease>;
|
|
16
|
+
}
|
|
5
17
|
export interface StartWorkersConfig {
|
|
6
18
|
/**
|
|
7
19
|
* Object map of the jobs that this scheduler will execute.
|
|
@@ -24,6 +36,12 @@ export interface StartWorkersConfig {
|
|
|
24
36
|
* configured retention period expires.
|
|
25
37
|
*/
|
|
26
38
|
onMaxTriesReached?: (job: JobToRun) => Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Optional infrastructure guard acquired after a job is claimed and before its resolver starts.
|
|
41
|
+
* The returned lease is held until the resolver's Promise settles, including late stale
|
|
42
|
+
* executions. Acquisition failures safely requeue the job without consuming a business try.
|
|
43
|
+
*/
|
|
44
|
+
executionGuard?: WorkerExecutionGuard;
|
|
27
45
|
/**
|
|
28
46
|
* Time in milliseconds to wait between each look without results for a job
|
|
29
47
|
* to run at the database. Default is 3000.
|