queue-jobs-worker 1.0.0
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/CHANGELOG.md +76 -0
- package/LICENSE +21 -0
- package/README.md +821 -0
- package/dist/core/backoff.d.ts +24 -0
- package/dist/core/backoff.d.ts.map +1 -0
- package/dist/core/client.d.ts +93 -0
- package/dist/core/client.d.ts.map +1 -0
- package/dist/core/id.d.ts +9 -0
- package/dist/core/id.d.ts.map +1 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/job.d.ts +75 -0
- package/dist/core/job.d.ts.map +1 -0
- package/dist/core/queue.d.ts +70 -0
- package/dist/core/queue.d.ts.map +1 -0
- package/dist/core/worker.d.ts +65 -0
- package/dist/core/worker.d.ts.map +1 -0
- package/dist/events/emitter.d.ts +24 -0
- package/dist/events/emitter.d.ts.map +1 -0
- package/dist/index.cjs +2229 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2219 -0
- package/dist/index.js.map +1 -0
- package/dist/storage/in-memory.adapter.d.ts +32 -0
- package/dist/storage/in-memory.adapter.d.ts.map +1 -0
- package/dist/storage/index.d.ts +5 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/mysql.adapter.d.ts +37 -0
- package/dist/storage/mysql.adapter.d.ts.map +1 -0
- package/dist/storage/postgres.adapter.d.ts +37 -0
- package/dist/storage/postgres.adapter.d.ts.map +1 -0
- package/dist/storage/redis.adapter.d.ts +44 -0
- package/dist/storage/redis.adapter.d.ts.map +1 -0
- package/dist/types/client.types.d.ts +41 -0
- package/dist/types/client.types.d.ts.map +1 -0
- package/dist/types/events.types.d.ts +22 -0
- package/dist/types/events.types.d.ts.map +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/job.types.d.ts +97 -0
- package/dist/types/job.types.d.ts.map +1 -0
- package/dist/types/queue.types.d.ts +43 -0
- package/dist/types/queue.types.d.ts.map +1 -0
- package/dist/types/storage.types.d.ts +120 -0
- package/dist/types/storage.types.d.ts.map +1 -0
- package/dist/types/worker.types.d.ts +25 -0
- package/dist/types/worker.types.d.ts.map +1 -0
- package/package.json +97 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RedisStorageAdapter (node-redis v4/v5)
|
|
3
|
+
*
|
|
4
|
+
* Key layout — prefix: "qjw:"
|
|
5
|
+
* ─────────────────────────────────────────────────────────────────────────
|
|
6
|
+
* qjw:job:{id} → Hash — all job fields (flat strings)
|
|
7
|
+
* qjw:queue:{name}:waiting → Sorted Set score = -priority
|
|
8
|
+
* (ZPOPMIN → highest priority first)
|
|
9
|
+
* qjw:queue:{name}:delayed → Sorted Set score = runAt epoch-ms
|
|
10
|
+
* qjw:queue:{name}:active → Set
|
|
11
|
+
* qjw:queue:{name}:completed → Set
|
|
12
|
+
* qjw:queue:{name}:dead → Set
|
|
13
|
+
* qjw:rate:{name} → String sliding-window counter
|
|
14
|
+
* qjw:rate:{name}:ts → String window-start epoch-ms
|
|
15
|
+
* ─────────────────────────────────────────────────────────────────────────
|
|
16
|
+
*
|
|
17
|
+
* Atomic claim
|
|
18
|
+
* ─────────────────────────────────────────────────────────────────────────
|
|
19
|
+
* A Lua script executed by Redis guarantees that two concurrent workers
|
|
20
|
+
* cannot claim the same job.
|
|
21
|
+
* ─────────────────────────────────────────────────────────────────────────
|
|
22
|
+
*/
|
|
23
|
+
import type { StorageAdapter } from "../types/storage.types.js";
|
|
24
|
+
import type { EnqueueInput, ClaimInput, RequeueInput, MoveToDlqInput, GetJobsFilter } from "../types/storage.types.js";
|
|
25
|
+
import type { JobData, JobStatus } from "../types/job.types.js";
|
|
26
|
+
export declare class RedisStorageAdapter implements StorageAdapter {
|
|
27
|
+
private client;
|
|
28
|
+
private readonly url;
|
|
29
|
+
constructor(connectionString: string);
|
|
30
|
+
initialize(): Promise<void>;
|
|
31
|
+
close(): Promise<void>;
|
|
32
|
+
enqueue<TPayload = unknown>(input: EnqueueInput<TPayload>): Promise<JobData<TPayload>>;
|
|
33
|
+
claim<TPayload = unknown>(input: ClaimInput): Promise<JobData<TPayload> | null>;
|
|
34
|
+
complete(jobId: string): Promise<void>;
|
|
35
|
+
requeue(input: RequeueInput): Promise<void>;
|
|
36
|
+
moveToDlq(input: MoveToDlqInput): Promise<void>;
|
|
37
|
+
releaseLock(jobId: string): Promise<void>;
|
|
38
|
+
recoverStalledJobs(queue: string, now: string): Promise<string[]>;
|
|
39
|
+
getJob<TPayload = unknown>(jobId: string): Promise<JobData<TPayload> | null>;
|
|
40
|
+
getJobs<TPayload = unknown>(filter: GetJobsFilter): Promise<JobData<TPayload>[]>;
|
|
41
|
+
getJobCounts(queue: string): Promise<Record<JobStatus, number>>;
|
|
42
|
+
checkAndIncrementRateLimit(queue: string, max: number, windowMs: number, now: string): Promise<boolean>;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=redis.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.adapter.d.ts","sourceRoot":"","sources":["../../src/storage/redis.adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,cAAc,EACd,aAAa,EACd,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAc,MAAM,uBAAuB,CAAC;AA+I5E,qBAAa,mBAAoB,YAAW,cAAc;IACxD,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;gBAEjB,gBAAgB,EAAE,MAAM;IAQ9B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAsB3B,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supported storage dialects.
|
|
3
|
+
*/
|
|
4
|
+
import type { BackoffStrategy } from "./job.types.js";
|
|
5
|
+
import type { RateLimitOptions } from "./queue.types.js";
|
|
6
|
+
export type StorageDialect = "memory" | "redis" | "postgres" | "mysql";
|
|
7
|
+
export interface ClientDefaults {
|
|
8
|
+
/** Default max attempts for all queues/jobs. Default: 3. */
|
|
9
|
+
attempts?: number;
|
|
10
|
+
/** Default base retry delay in ms. Default: 1 000. */
|
|
11
|
+
retryDelay?: number;
|
|
12
|
+
/** Default backoff strategy. Default: "exponential". */
|
|
13
|
+
backoff?: BackoffStrategy;
|
|
14
|
+
/** Default per-attempt timeout in ms. Default: 30 000. */
|
|
15
|
+
timeout?: number;
|
|
16
|
+
/** Default worker concurrency. Default: 10. */
|
|
17
|
+
concurrency?: number;
|
|
18
|
+
/** Default rate limiting. */
|
|
19
|
+
rateLimit?: RateLimitOptions;
|
|
20
|
+
/** Default polling interval in ms. Default: 1 000. */
|
|
21
|
+
pollInterval?: number;
|
|
22
|
+
/** Default stalled-job check interval in ms. Default: 30 000. */
|
|
23
|
+
stalledInterval?: number;
|
|
24
|
+
/** Default lock duration in ms. Default: 60 000. */
|
|
25
|
+
lockDuration?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface QueueClientOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Storage backend to use.
|
|
30
|
+
* Default: "memory" (in-process, non-persistent — for development/testing).
|
|
31
|
+
*/
|
|
32
|
+
dialect?: StorageDialect;
|
|
33
|
+
/**
|
|
34
|
+
* Connection string for the selected storage backend.
|
|
35
|
+
* Not required for the "memory" dialect.
|
|
36
|
+
*/
|
|
37
|
+
connectionString?: string;
|
|
38
|
+
/** Global defaults applied to all queues and workers. */
|
|
39
|
+
defaults?: ClientDefaults;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=client.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.types.d.ts","sourceRoot":"","sources":["../../src/types/client.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAMzD,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,OAAO,CAAC;AAMvE,MAAM,WAAW,cAAc;IAC7B,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,sDAAsD;IACtD,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,wDAAwD;IACxD,OAAO,CAAC,EAAE,eAAe,CAAC;IAE1B,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAE7B,sDAAsD;IACtD,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,iEAAiE;IACjE,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,oDAAoD;IACpD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAMD,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC;IAEzB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,yDAAyD;IACzD,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* All event names and their payload types for QueueEventEmitter.
|
|
3
|
+
*/
|
|
4
|
+
import type { JobData } from "./job.types.js";
|
|
5
|
+
import type { WorkerStatus } from "./worker.types.js";
|
|
6
|
+
export interface QueueEvents<TPayload = unknown> {
|
|
7
|
+
"job:enqueued": [job: JobData<TPayload>];
|
|
8
|
+
"job:started": [job: JobData<TPayload>];
|
|
9
|
+
"job:completed": [job: JobData<TPayload>];
|
|
10
|
+
"job:failed": [job: JobData<TPayload>, error: Error];
|
|
11
|
+
"job:retrying": [job: JobData<TPayload>, error: Error, nextRunAt: string];
|
|
12
|
+
"job:dead": [job: JobData<TPayload>, error: Error];
|
|
13
|
+
"job:stalled": [jobId: string];
|
|
14
|
+
"job:recovered": [jobId: string];
|
|
15
|
+
"worker:started": [workerId: string];
|
|
16
|
+
"worker:stopped": [workerId: string];
|
|
17
|
+
"worker:status": [workerId: string, status: WorkerStatus];
|
|
18
|
+
"worker:error": [workerId: string, error: Error];
|
|
19
|
+
"queue:error": [queueName: string, error: Error];
|
|
20
|
+
error: [error: Error];
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=events.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.types.d.ts","sourceRoot":"","sources":["../../src/types/events.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAMtD,MAAM,WAAW,WAAW,CAAC,QAAQ,GAAG,OAAO;IAE7C,cAAc,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IACzC,aAAa,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxC,eAAe,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1C,YAAY,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IACrD,cAAc,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAC1E,UAAU,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IACnD,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC/B,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAGjC,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACrC,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACrC,eAAe,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;IAC1D,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAGjD,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAGjD,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;CACvB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public type re-exports.
|
|
3
|
+
*/
|
|
4
|
+
export type { JobStatus, JobAttempt, JobSchedule, JobOptions, BackoffStrategy, JobData, } from "./job.types.js";
|
|
5
|
+
export type { RateLimitOptions, QueueOptions } from "./queue.types.js";
|
|
6
|
+
export type { Processor, WorkerOptions, WorkerStatus } from "./worker.types.js";
|
|
7
|
+
export type { StorageAdapter, EnqueueInput, ClaimInput, ClaimResult, RequeueInput, MoveToDlqInput, GetJobsFilter, } from "./storage.types.js";
|
|
8
|
+
export type { StorageDialect, ClientDefaults, QueueClientOptions } from "./client.types.js";
|
|
9
|
+
export type { QueueEvents } from "./events.types.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EACV,SAAS,EACT,UAAU,EACV,WAAW,EACX,UAAU,EACV,eAAe,EACf,OAAO,GACR,MAAM,gBAAgB,CAAC;AAExB,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEvE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEhF,YAAY,EACV,cAAc,EACd,YAAY,EACZ,UAAU,EACV,WAAW,EACX,YAAY,EACZ,cAAc,EACd,aAAa,GACd,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5F,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* All types related to Job identity, state, configuration, and lifecycle.
|
|
3
|
+
*/
|
|
4
|
+
export type JobStatus = "waiting" | "active" | "completed" | "delayed" | "dead";
|
|
5
|
+
export interface JobAttempt {
|
|
6
|
+
/** 1-based attempt number. */
|
|
7
|
+
readonly attempt: number;
|
|
8
|
+
/** ISO timestamp when this attempt started. */
|
|
9
|
+
readonly startedAt: string;
|
|
10
|
+
/** ISO timestamp when this attempt finished (success or failure). */
|
|
11
|
+
readonly finishedAt: string;
|
|
12
|
+
/** Error message if the attempt failed. */
|
|
13
|
+
readonly error?: string;
|
|
14
|
+
/** Error stack trace if the attempt failed (never logged by default). */
|
|
15
|
+
readonly stack?: string | undefined;
|
|
16
|
+
}
|
|
17
|
+
export interface JobSchedule {
|
|
18
|
+
/**
|
|
19
|
+
* Delay in milliseconds before the job becomes eligible.
|
|
20
|
+
* Mutually exclusive with `runAt`.
|
|
21
|
+
*/
|
|
22
|
+
delay?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Absolute timestamp (ISO string or epoch ms) when the job becomes eligible.
|
|
25
|
+
* Mutually exclusive with `delay`.
|
|
26
|
+
*/
|
|
27
|
+
runAt?: string | number;
|
|
28
|
+
/**
|
|
29
|
+
* Cron expression for recurring jobs.
|
|
30
|
+
* When set the job re-enqueues itself after each successful execution.
|
|
31
|
+
*/
|
|
32
|
+
cron?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface JobOptions {
|
|
35
|
+
/** Maximum number of processing attempts (default: inherited from queue/client). */
|
|
36
|
+
attempts?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Base delay in milliseconds between retry attempts.
|
|
39
|
+
* Used by the backoff strategy.
|
|
40
|
+
*/
|
|
41
|
+
retryDelay?: number;
|
|
42
|
+
/** Backoff strategy applied on retry. */
|
|
43
|
+
backoff?: BackoffStrategy;
|
|
44
|
+
/** Maximum execution time in milliseconds for a single attempt. */
|
|
45
|
+
timeout?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Priority value — higher numbers are processed first.
|
|
48
|
+
* Default: 0.
|
|
49
|
+
*/
|
|
50
|
+
priority?: number;
|
|
51
|
+
/** Scheduling options (delay / runAt / cron). */
|
|
52
|
+
schedule?: JobSchedule;
|
|
53
|
+
}
|
|
54
|
+
export type BackoffStrategy = "fixed" | "exponential" | "linear";
|
|
55
|
+
export interface JobData<TPayload = unknown> {
|
|
56
|
+
/** Unique, stable job identifier. */
|
|
57
|
+
readonly id: string;
|
|
58
|
+
/** Name of the queue this job belongs to. */
|
|
59
|
+
readonly queue: string;
|
|
60
|
+
/** Application-defined job type (matches processor registration). */
|
|
61
|
+
readonly type: string;
|
|
62
|
+
/** User-supplied job payload. Never logged by default. */
|
|
63
|
+
readonly payload: TPayload;
|
|
64
|
+
/** Current lifecycle status. */
|
|
65
|
+
status: JobStatus;
|
|
66
|
+
/** Number of attempts already executed (0 = not yet started). */
|
|
67
|
+
attemptsMade: number;
|
|
68
|
+
/** Maximum allowed attempts. */
|
|
69
|
+
maxAttempts: number;
|
|
70
|
+
/** Base delay in ms between retries. */
|
|
71
|
+
retryDelay: number;
|
|
72
|
+
/** Backoff strategy. */
|
|
73
|
+
backoff: BackoffStrategy;
|
|
74
|
+
/** Per-attempt timeout in ms. */
|
|
75
|
+
timeout: number;
|
|
76
|
+
/** Processing priority — higher = sooner. */
|
|
77
|
+
priority: number;
|
|
78
|
+
/** ISO timestamp when the job is eligible to run (for delayed/scheduled jobs). */
|
|
79
|
+
runAt: string;
|
|
80
|
+
/** Cron expression (recurring jobs only). */
|
|
81
|
+
cron?: string | undefined;
|
|
82
|
+
/** Ordered list of past attempt records. */
|
|
83
|
+
attempts: JobAttempt[];
|
|
84
|
+
/** ID of the worker lock currently owning this job (null when not active). */
|
|
85
|
+
lockId: string | null;
|
|
86
|
+
/** ISO timestamp when the current lock expires. */
|
|
87
|
+
lockExpiresAt: string | null;
|
|
88
|
+
/** ISO timestamp when the job was enqueued. */
|
|
89
|
+
readonly createdAt: string;
|
|
90
|
+
/** ISO timestamp of the last status change. */
|
|
91
|
+
updatedAt: string;
|
|
92
|
+
/** ISO timestamp when processing completed successfully. */
|
|
93
|
+
completedAt: string | null;
|
|
94
|
+
/** ISO timestamp when the job was moved to the DLQ. */
|
|
95
|
+
failedAt: string | null;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=job.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job.types.d.ts","sourceRoot":"","sources":["../../src/types/job.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,QAAQ,GACR,WAAW,GACX,SAAS,GACT,MAAM,CAAC;AAMX,MAAM,WAAW,UAAU;IACzB,8BAA8B;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,+CAA+C;IAC/C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,qEAAqE;IACrE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,2CAA2C;IAC3C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,yEAAyE;IACzE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SA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kF;IAClF,KAAK,EAAE,MAAM,CAAC;IAEd,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE1B,4CAA4C;IAC5C,QAAQ,EAAE,UAAU,EAAE,CAAC;IAEvB,8EAA8E;IAC9E,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtB,mDAAmD;IACnD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAE7B,+CAA+C;IAC/C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;IAElB,4DAA4D;IAC5D,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAE3B,uDAAuD;IACvD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for Queue configuration and queue-level options.
|
|
3
|
+
*/
|
|
4
|
+
import type { BackoffStrategy } from "./job.types.js";
|
|
5
|
+
export interface RateLimitOptions {
|
|
6
|
+
/** Maximum number of jobs to process within `duration`. */
|
|
7
|
+
max: number;
|
|
8
|
+
/** Time window in milliseconds. */
|
|
9
|
+
duration: number;
|
|
10
|
+
}
|
|
11
|
+
export interface QueueOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Maximum concurrent jobs processed across all workers of this queue.
|
|
14
|
+
* Default: 10.
|
|
15
|
+
*/
|
|
16
|
+
concurrency?: number;
|
|
17
|
+
/** Default max attempts for jobs in this queue. */
|
|
18
|
+
attempts?: number;
|
|
19
|
+
/** Default base retry delay in ms for jobs in this queue. */
|
|
20
|
+
retryDelay?: number;
|
|
21
|
+
/** Default backoff strategy. */
|
|
22
|
+
backoff?: BackoffStrategy;
|
|
23
|
+
/** Default per-attempt timeout in ms. */
|
|
24
|
+
timeout?: number;
|
|
25
|
+
/** Queue-level rate limiting. */
|
|
26
|
+
rateLimit?: RateLimitOptions;
|
|
27
|
+
/**
|
|
28
|
+
* Interval in ms between each poll cycle (how often the worker checks for
|
|
29
|
+
* new jobs). Default: 1 000 ms.
|
|
30
|
+
*/
|
|
31
|
+
pollInterval?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Interval in ms between stalled-job recovery checks.
|
|
34
|
+
* Default: 30 000 ms.
|
|
35
|
+
*/
|
|
36
|
+
stalledInterval?: number;
|
|
37
|
+
/**
|
|
38
|
+
* How long a lock is valid before it is considered expired.
|
|
39
|
+
* Default: 60 000 ms.
|
|
40
|
+
*/
|
|
41
|
+
lockDuration?: number;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=queue.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.types.d.ts","sourceRoot":"","sources":["../../src/types/queue.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAMtD,MAAM,WAAW,gBAAgB;IAC/B,2DAA2D;IAC3D,GAAG,EAAE,MAAM,CAAC;IACZ,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAMD,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,6DAA6D;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,gCAAgC;IAChC,OAAO,CAAC,EAAE,eAAe,CAAC;IAE1B,yCAAyC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,iCAAiC;IACjC,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAE7B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the StorageAdapter abstraction.
|
|
3
|
+
*/
|
|
4
|
+
import type { JobData, JobStatus, BackoffStrategy } from "./job.types.js";
|
|
5
|
+
export interface EnqueueInput<TPayload = unknown> {
|
|
6
|
+
id: string;
|
|
7
|
+
queue: string;
|
|
8
|
+
type: string;
|
|
9
|
+
payload: TPayload;
|
|
10
|
+
maxAttempts: number;
|
|
11
|
+
retryDelay: number;
|
|
12
|
+
backoff: BackoffStrategy;
|
|
13
|
+
timeout: number;
|
|
14
|
+
priority: number;
|
|
15
|
+
runAt: string;
|
|
16
|
+
cron?: string | undefined;
|
|
17
|
+
}
|
|
18
|
+
export interface ClaimInput {
|
|
19
|
+
queue: string;
|
|
20
|
+
lockId: string;
|
|
21
|
+
lockDuration: number;
|
|
22
|
+
now: string;
|
|
23
|
+
}
|
|
24
|
+
export interface ClaimResult<TPayload = unknown> {
|
|
25
|
+
job: JobData<TPayload>;
|
|
26
|
+
}
|
|
27
|
+
export interface RequeueInput {
|
|
28
|
+
jobId: string;
|
|
29
|
+
runAt: string;
|
|
30
|
+
error: string;
|
|
31
|
+
stack?: string | undefined;
|
|
32
|
+
/** 1-based attempt number that just failed (used to populate attempt history). */
|
|
33
|
+
attemptNumber: number;
|
|
34
|
+
}
|
|
35
|
+
export interface MoveToDlqInput {
|
|
36
|
+
jobId: string;
|
|
37
|
+
error: string;
|
|
38
|
+
stack?: string | undefined;
|
|
39
|
+
/** 1-based attempt number that just failed (used to populate attempt history). */
|
|
40
|
+
attemptNumber: number;
|
|
41
|
+
}
|
|
42
|
+
export interface GetJobsFilter {
|
|
43
|
+
queue?: string | undefined;
|
|
44
|
+
status?: JobStatus | undefined;
|
|
45
|
+
limit?: number | undefined;
|
|
46
|
+
offset?: number | undefined;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* StorageAdapter is the only way the core interacts with persistence.
|
|
50
|
+
*
|
|
51
|
+
* All implementations must honour the atomicity requirements documented on each
|
|
52
|
+
* method.
|
|
53
|
+
*/
|
|
54
|
+
export interface StorageAdapter {
|
|
55
|
+
/**
|
|
56
|
+
* Initialise the adapter (create tables, indexes, connection pools, etc.).
|
|
57
|
+
* Called once by QueueClient before any queue or worker operation.
|
|
58
|
+
*/
|
|
59
|
+
initialize(): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Tear down the adapter (close connections, flush buffers).
|
|
62
|
+
* Called once when the client is closing.
|
|
63
|
+
*/
|
|
64
|
+
close(): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Persist a new job in `waiting` (or `delayed`) status.
|
|
67
|
+
* Must be idempotent when called with the same `id`.
|
|
68
|
+
*/
|
|
69
|
+
enqueue<TPayload = unknown>(input: EnqueueInput<TPayload>): Promise<JobData<TPayload>>;
|
|
70
|
+
/**
|
|
71
|
+
* Atomically claim the next eligible job in `queue`.
|
|
72
|
+
*
|
|
73
|
+
* Eligible means:
|
|
74
|
+
* - status === 'waiting'
|
|
75
|
+
* - runAt <= now
|
|
76
|
+
* - no valid (non-expired) lock held
|
|
77
|
+
*
|
|
78
|
+
* The implementation MUST guarantee that concurrent callers cannot claim the
|
|
79
|
+
* same job. Returns `null` when no eligible job is found.
|
|
80
|
+
*/
|
|
81
|
+
claim<TPayload = unknown>(input: ClaimInput): Promise<JobData<TPayload> | null>;
|
|
82
|
+
/**
|
|
83
|
+
* Mark a job as successfully completed and release its lock.
|
|
84
|
+
*/
|
|
85
|
+
complete(jobId: string): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Requeue a failed job for another attempt (retry).
|
|
88
|
+
* Records the failure in `attempts` history.
|
|
89
|
+
* Must NOT create a new job identity.
|
|
90
|
+
*/
|
|
91
|
+
requeue(input: RequeueInput): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* Move a permanently-failed job to the DLQ.
|
|
94
|
+
* Sets status to `'dead'` and records the final failure.
|
|
95
|
+
*/
|
|
96
|
+
moveToDlq(input: MoveToDlqInput): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Release the lock on a job without changing its status.
|
|
99
|
+
* Used during graceful shutdown when a job cannot complete in time.
|
|
100
|
+
*/
|
|
101
|
+
releaseLock(jobId: string): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Recover stalled jobs — jobs that are `active` but whose lock has expired.
|
|
104
|
+
* Returns the list of recovered job IDs.
|
|
105
|
+
*/
|
|
106
|
+
recoverStalledJobs(queue: string, now: string): Promise<string[]>;
|
|
107
|
+
/** Fetch a single job by its ID. Returns `null` if not found. */
|
|
108
|
+
getJob<TPayload = unknown>(jobId: string): Promise<JobData<TPayload> | null>;
|
|
109
|
+
/** Fetch multiple jobs matching the given filter. */
|
|
110
|
+
getJobs<TPayload = unknown>(filter: GetJobsFilter): Promise<JobData<TPayload>[]>;
|
|
111
|
+
/** Count jobs by status in a queue. */
|
|
112
|
+
getJobCounts(queue: string): Promise<Record<JobStatus, number>>;
|
|
113
|
+
/**
|
|
114
|
+
* Increment the rate-limit counter for `queue` within the current window.
|
|
115
|
+
* Returns `true` when the job is allowed to proceed, `false` when the rate
|
|
116
|
+
* limit has been reached.
|
|
117
|
+
*/
|
|
118
|
+
checkAndIncrementRateLimit(queue: string, max: number, windowMs: number, now: string): Promise<boolean>;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=storage.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.types.d.ts","sourceRoot":"","sources":["../../src/types/storage.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAM1E,MAAM,WAAW,YAAY,CAAC,QAAQ,GAAG,OAAO;IAC9C,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,QAAQ,CAAC;IAClB,WAAW,EAAE,MAAM,CA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E,MAAM,EACb,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,OAAO,CAAC,CAAC;CACrB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for Worker configuration, processor functions, and worker state.
|
|
3
|
+
*/
|
|
4
|
+
import type { Job } from "../core/job.js";
|
|
5
|
+
/**
|
|
6
|
+
* A user-supplied function that handles a single job.
|
|
7
|
+
*
|
|
8
|
+
* Must resolve to indicate success.
|
|
9
|
+
* Throwing (or rejecting) marks the job as failed for this attempt.
|
|
10
|
+
*/
|
|
11
|
+
export type Processor<TPayload = unknown> = (job: Job<TPayload>) => Promise<void>;
|
|
12
|
+
export interface WorkerOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Maximum number of jobs processed concurrently by this worker.
|
|
15
|
+
* Overrides the queue-level concurrency setting.
|
|
16
|
+
*/
|
|
17
|
+
concurrency?: number;
|
|
18
|
+
/**
|
|
19
|
+
* How long to wait for active jobs to finish during graceful shutdown (ms).
|
|
20
|
+
* Default: 30 000 ms.
|
|
21
|
+
*/
|
|
22
|
+
shutdownTimeout?: number;
|
|
23
|
+
}
|
|
24
|
+
export type WorkerStatus = "idle" | "running" | "stopping" | "stopped";
|
|
25
|
+
//# sourceMappingURL=worker.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.types.d.ts","sourceRoot":"","sources":["../../src/types/worker.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAM1C;;;;;GAKG;AACH,MAAM,MAAM,SAAS,CAAC,QAAQ,GAAG,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAMlF,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAMD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "queue-jobs-worker",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Reliable job queue and background worker system for Node.js with retries, concurrency, scheduling, and failure recovery.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"queue",
|
|
7
|
+
"job-queue",
|
|
8
|
+
"background-jobs",
|
|
9
|
+
"background-processing",
|
|
10
|
+
"worker",
|
|
11
|
+
"nodejs",
|
|
12
|
+
"retry",
|
|
13
|
+
"concurrency",
|
|
14
|
+
"scheduling",
|
|
15
|
+
"dlq",
|
|
16
|
+
"dead-letter-queue",
|
|
17
|
+
"redis",
|
|
18
|
+
"postgres",
|
|
19
|
+
"mysql",
|
|
20
|
+
"typescript"
|
|
21
|
+
],
|
|
22
|
+
"homepage": "https://github.com/rafidahmed870/queue-jobs-worker#readme",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/rafidahmed870/queue-jobs-worker/issues"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/rafidahmed870/queue-jobs-worker.git"
|
|
29
|
+
},
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"author": "Rafid Ahmed",
|
|
32
|
+
"type": "module",
|
|
33
|
+
"main": "./dist/index.cjs",
|
|
34
|
+
"module": "./dist/index.js",
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"import": {
|
|
39
|
+
"types": "./dist/index.d.ts",
|
|
40
|
+
"default": "./dist/index.js"
|
|
41
|
+
},
|
|
42
|
+
"require": {
|
|
43
|
+
"types": "./dist/index.d.ts",
|
|
44
|
+
"default": "./dist/index.cjs"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"sideEffects": false,
|
|
49
|
+
"files": [
|
|
50
|
+
"dist",
|
|
51
|
+
"README.md",
|
|
52
|
+
"CHANGELOG.md",
|
|
53
|
+
"LICENSE"
|
|
54
|
+
],
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "tsup && tsc -p tsconfig.dts.json",
|
|
57
|
+
"dev": "tsup --watch",
|
|
58
|
+
"typecheck": "tsc --noEmit",
|
|
59
|
+
"lint": "eslint .",
|
|
60
|
+
"lint:fix": "eslint . --fix",
|
|
61
|
+
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
62
|
+
"format:check": "prettier --check \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
63
|
+
"test": "vitest run",
|
|
64
|
+
"test:watch": "vitest",
|
|
65
|
+
"test:coverage": "vitest run --coverage",
|
|
66
|
+
"prepublishOnly": "npm run typecheck && npm run build"
|
|
67
|
+
},
|
|
68
|
+
"engines": {
|
|
69
|
+
"node": ">=18.0.0"
|
|
70
|
+
},
|
|
71
|
+
"peerDependencies": {
|
|
72
|
+
"redis": ">=4.0.0",
|
|
73
|
+
"pg": ">=8.0.0",
|
|
74
|
+
"mysql2": ">=3.0.0"
|
|
75
|
+
},
|
|
76
|
+
"peerDependenciesMeta": {
|
|
77
|
+
"redis": { "optional": true },
|
|
78
|
+
"pg": { "optional": true },
|
|
79
|
+
"mysql2": { "optional": true }
|
|
80
|
+
},
|
|
81
|
+
"devDependencies": {
|
|
82
|
+
"@types/node": "*",
|
|
83
|
+
"@types/pg": "^8.23.1",
|
|
84
|
+
"@typescript-eslint/eslint-plugin": "*",
|
|
85
|
+
"@typescript-eslint/parser": "*",
|
|
86
|
+
"eslint": "*",
|
|
87
|
+
"eslint-config-prettier": "*",
|
|
88
|
+
"eslint-plugin-prettier": "*",
|
|
89
|
+
"mysql2": "^3.24.2",
|
|
90
|
+
"pg": "^8.23.0",
|
|
91
|
+
"prettier": "*",
|
|
92
|
+
"redis": "^6.2.1",
|
|
93
|
+
"tsup": "*",
|
|
94
|
+
"typescript": "*",
|
|
95
|
+
"vitest": "*"
|
|
96
|
+
}
|
|
97
|
+
}
|