@orion-js/dogs 4.6.2 → 4.6.5
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 +461 -204
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +454 -197
- package/dist/index.js.map +1 -1
- package/dist/repos/JobsRepo.d.ts +19 -3
- package/dist/schedule.d.ts +4 -0
- package/dist/services/EventsService.d.ts +2 -2
- package/dist/services/WorkerService.d.ts +13 -0
- package/dist/services/partitions.d.ts +3 -0
- package/dist/types/Events.d.ts +1 -0
- package/dist/types/JobRecord.d.ts +15 -0
- package/dist/types/JobsDefinition.d.ts +2 -0
- package/dist/types/StartConfig.d.ts +5 -0
- package/package.json +4 -3
package/dist/types/Events.d.ts
CHANGED
|
@@ -49,6 +49,7 @@ export interface ScheduleJobRecordOptions {
|
|
|
49
49
|
nextRunAt: Date;
|
|
50
50
|
priority: number;
|
|
51
51
|
uniqueIdentifier?: string;
|
|
52
|
+
partition?: number;
|
|
52
53
|
}
|
|
53
54
|
export type ScheduleJobsOptions<TParamsSchema extends SchemaInAnyOrionForm = any> = ScheduleJobOptions<TParamsSchema>[];
|
|
54
55
|
export interface ScheduleJobsResult {
|
|
@@ -25,6 +25,13 @@ export declare const JobRecordSchema: {
|
|
|
25
25
|
nextRunAt: {
|
|
26
26
|
type: "date";
|
|
27
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* Acquisition partition. Optional so records created by previous versions can be reconciled.
|
|
30
|
+
*/
|
|
31
|
+
partition: {
|
|
32
|
+
type: "number";
|
|
33
|
+
optional: true;
|
|
34
|
+
};
|
|
28
35
|
lastRunAt: {
|
|
29
36
|
type: "date";
|
|
30
37
|
optional: true;
|
|
@@ -41,6 +48,14 @@ export declare const JobRecordSchema: {
|
|
|
41
48
|
type: "string";
|
|
42
49
|
optional: true;
|
|
43
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* Internal acquisition metadata used when MongoDB supports sorted updateOne. It preserves the
|
|
53
|
+
* pre-update stale state because updateOne intentionally does not return the previous document.
|
|
54
|
+
*/
|
|
55
|
+
claimWasStale: {
|
|
56
|
+
type: "boolean";
|
|
57
|
+
optional: true;
|
|
58
|
+
};
|
|
44
59
|
tries: {
|
|
45
60
|
type: "number";
|
|
46
61
|
optional: true;
|
|
@@ -29,6 +29,8 @@ export interface BaseJobDefinition {
|
|
|
29
29
|
* This is set automatically when the job is passed to startWorkers.
|
|
30
30
|
*/
|
|
31
31
|
jobName?: string;
|
|
32
|
+
/** @internal Set when the job is registered in startWorkers. */
|
|
33
|
+
nPartitions?: number;
|
|
32
34
|
/**
|
|
33
35
|
* Time in milliseconds to lock this specific job for execution.
|
|
34
36
|
* Overrides the defaultLockTime set in startWorkers config.
|
|
@@ -38,6 +38,11 @@ export interface StartWorkersConfig {
|
|
|
38
38
|
* Maximum number of concurrent job executions for this scheduler. Default is 4.
|
|
39
39
|
*/
|
|
40
40
|
workersCount?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Number of database partitions used to spread job acquisition contention.
|
|
43
|
+
* Each claim queries exactly one partition. Default is 1.
|
|
44
|
+
*/
|
|
45
|
+
nPartitions?: number;
|
|
41
46
|
/**
|
|
42
47
|
* Default time in milliseconds to lock a job for execution. Default is 30000 (30 seconds).
|
|
43
48
|
* If a job is locked for longer than this time, it will be considered as failed.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orion-js/dogs",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@orion-js/logger": "4.5.0",
|
|
31
|
-
"@orion-js/mongodb": "4.5.
|
|
31
|
+
"@orion-js/mongodb": "4.5.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@orion-js/logger": "4.5.0",
|
|
35
|
-
"@orion-js/mongodb": "4.5.
|
|
35
|
+
"@orion-js/mongodb": "4.5.2",
|
|
36
36
|
"mongodb-memory-server": "^10.1.4",
|
|
37
37
|
"tsup": "^8.0.1",
|
|
38
38
|
"typescript": "^7.0.2"
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"gitHead": "2d14bc085d49a33b2a5566bec1caf60c7d0f897e",
|
|
44
44
|
"scripts": {
|
|
45
45
|
"test": "bun test",
|
|
46
|
+
"stress:acquisition": "DOGS_RUN_STRESS_TEST=1 bun test --cwd ../.. packages/dogs/scripts/stress-job-acquisition.test.ts",
|
|
46
47
|
"clean": "rm -rf ./dist",
|
|
47
48
|
"build": "tsup && bun run ../../scripts/emit-declarations.ts",
|
|
48
49
|
"dev": "tsup --watch"
|