@igniter-js/jobs 0.1.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/AGENTS.md +557 -0
- package/README.md +410 -0
- package/dist/adapter-CcQCatSa.d.mts +1411 -0
- package/dist/adapter-CcQCatSa.d.ts +1411 -0
- package/dist/adapters/bullmq.adapter.d.mts +131 -0
- package/dist/adapters/bullmq.adapter.d.ts +131 -0
- package/dist/adapters/bullmq.adapter.js +598 -0
- package/dist/adapters/bullmq.adapter.js.map +1 -0
- package/dist/adapters/bullmq.adapter.mjs +596 -0
- package/dist/adapters/bullmq.adapter.mjs.map +1 -0
- package/dist/adapters/index.d.mts +5 -0
- package/dist/adapters/index.d.ts +5 -0
- package/dist/adapters/index.js +1129 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/index.mjs +1126 -0
- package/dist/adapters/index.mjs.map +1 -0
- package/dist/adapters/memory.adapter.d.mts +118 -0
- package/dist/adapters/memory.adapter.d.ts +118 -0
- package/dist/adapters/memory.adapter.js +571 -0
- package/dist/adapters/memory.adapter.js.map +1 -0
- package/dist/adapters/memory.adapter.mjs +569 -0
- package/dist/adapters/memory.adapter.mjs.map +1 -0
- package/dist/index.d.mts +1107 -0
- package/dist/index.d.ts +1107 -0
- package/dist/index.js +1137 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1128 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +93 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { Redis } from 'ioredis';
|
|
2
|
+
import { I as IgniterJobsAdapter, A as AdapterDispatchParams, a as AdapterScheduleParams, b as IgniterJobInfo, c as IgniterJobStatus, d as IgniterJobLog, e as IgniterQueueInfo, f as IgniterQueueCleanOptions, g as IgniterJobCounts, h as IgniterJobSearchResult, i as IgniterJobEventHandler, j as IgniterJobUnsubscribeFn, k as AdapterWorkerConfig, l as AdapterJobHandler, m as AdapterWorkerHandle } from '../adapter-CcQCatSa.mjs';
|
|
3
|
+
import '@igniter-js/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @fileoverview BullMQ adapter for @igniter-js/jobs
|
|
7
|
+
* @module @igniter-js/jobs/adapters/bullmq
|
|
8
|
+
*
|
|
9
|
+
* @description
|
|
10
|
+
* Provides BullMQ-based implementation of the IgniterJobsAdapter interface.
|
|
11
|
+
* Requires Redis connection via ioredis.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { BullMQAdapter } from '@igniter-js/jobs/adapters'
|
|
16
|
+
* import Redis from 'ioredis'
|
|
17
|
+
*
|
|
18
|
+
* const redis = new Redis()
|
|
19
|
+
* const adapter = BullMQAdapter.create({ redis })
|
|
20
|
+
*
|
|
21
|
+
* const jobs = IgniterJobs.create<AppContext>()
|
|
22
|
+
* .withAdapter(adapter)
|
|
23
|
+
* .build()
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* BullMQ adapter options.
|
|
29
|
+
*/
|
|
30
|
+
interface BullMQAdapterOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Redis connection (ioredis instance).
|
|
33
|
+
*/
|
|
34
|
+
redis: Redis;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* BullMQ implementation of IgniterJobsAdapter.
|
|
38
|
+
*/
|
|
39
|
+
declare class BullMQAdapter implements IgniterJobsAdapter {
|
|
40
|
+
private readonly redis;
|
|
41
|
+
private readonly queues;
|
|
42
|
+
private readonly workers;
|
|
43
|
+
private readonly queueEvents;
|
|
44
|
+
private BullMQ;
|
|
45
|
+
private constructor();
|
|
46
|
+
/**
|
|
47
|
+
* Create a new BullMQ adapter.
|
|
48
|
+
*
|
|
49
|
+
* @param options - Adapter options with Redis connection
|
|
50
|
+
* @returns A new BullMQAdapter instance
|
|
51
|
+
*/
|
|
52
|
+
static create(options: BullMQAdapterOptions): BullMQAdapter;
|
|
53
|
+
/**
|
|
54
|
+
* Get the underlying Redis client.
|
|
55
|
+
*/
|
|
56
|
+
get client(): Redis;
|
|
57
|
+
/**
|
|
58
|
+
* Lazily load BullMQ module.
|
|
59
|
+
*/
|
|
60
|
+
private getBullMQ;
|
|
61
|
+
/**
|
|
62
|
+
* Get or create a queue instance.
|
|
63
|
+
*/
|
|
64
|
+
private getOrCreateQueue;
|
|
65
|
+
/**
|
|
66
|
+
* Get or create queue events instance.
|
|
67
|
+
*/
|
|
68
|
+
private getQueueEvents;
|
|
69
|
+
/**
|
|
70
|
+
* Convert BullMQ job state to IgniterJobStatus.
|
|
71
|
+
*/
|
|
72
|
+
private mapJobState;
|
|
73
|
+
/**
|
|
74
|
+
* Convert BullMQ job to IgniterJobInfo.
|
|
75
|
+
*/
|
|
76
|
+
private mapJobToInfo;
|
|
77
|
+
dispatch(params: AdapterDispatchParams): Promise<string>;
|
|
78
|
+
schedule(params: AdapterScheduleParams): Promise<string>;
|
|
79
|
+
getJob(queue: string, jobId: string): Promise<IgniterJobInfo | null>;
|
|
80
|
+
getJobState(queue: string, jobId: string): Promise<IgniterJobStatus | null>;
|
|
81
|
+
getJobProgress(queue: string, jobId: string): Promise<number>;
|
|
82
|
+
getJobLogs(queue: string, jobId: string): Promise<IgniterJobLog[]>;
|
|
83
|
+
retryJob(queue: string, jobId: string): Promise<void>;
|
|
84
|
+
removeJob(queue: string, jobId: string): Promise<void>;
|
|
85
|
+
promoteJob(queue: string, jobId: string): Promise<void>;
|
|
86
|
+
moveJob(queue: string, jobId: string, state: 'failed' | 'completed', reason?: string): Promise<void>;
|
|
87
|
+
retryJobs(queue: string, jobIds: string[]): Promise<void>;
|
|
88
|
+
removeJobs(queue: string, jobIds: string[]): Promise<void>;
|
|
89
|
+
getQueue(queue: string): Promise<IgniterQueueInfo>;
|
|
90
|
+
pauseQueue(queue: string): Promise<void>;
|
|
91
|
+
resumeQueue(queue: string): Promise<void>;
|
|
92
|
+
drainQueue(queue: string): Promise<number>;
|
|
93
|
+
cleanQueue(queue: string, options: IgniterQueueCleanOptions): Promise<number>;
|
|
94
|
+
obliterateQueue(queue: string, options?: {
|
|
95
|
+
force?: boolean;
|
|
96
|
+
}): Promise<void>;
|
|
97
|
+
retryAllFailed(queue: string): Promise<number>;
|
|
98
|
+
getJobCounts(queue: string): Promise<IgniterJobCounts>;
|
|
99
|
+
listJobs(queue: string, options?: {
|
|
100
|
+
status?: IgniterJobStatus[];
|
|
101
|
+
start?: number;
|
|
102
|
+
end?: number;
|
|
103
|
+
}): Promise<IgniterJobSearchResult[]>;
|
|
104
|
+
pauseJobType(queue: string, jobName: string): Promise<void>;
|
|
105
|
+
resumeJobType(queue: string, jobName: string): Promise<void>;
|
|
106
|
+
private config?;
|
|
107
|
+
subscribe(pattern: string, handler: IgniterJobEventHandler): Promise<IgniterJobUnsubscribeFn>;
|
|
108
|
+
private matchesPattern;
|
|
109
|
+
createWorker(config: AdapterWorkerConfig, handler: AdapterJobHandler): Promise<AdapterWorkerHandle>;
|
|
110
|
+
searchJobs(filter: {
|
|
111
|
+
status?: IgniterJobStatus[];
|
|
112
|
+
queue?: string;
|
|
113
|
+
jobName?: string;
|
|
114
|
+
scopeId?: string;
|
|
115
|
+
actorId?: string;
|
|
116
|
+
dateRange?: {
|
|
117
|
+
from?: Date;
|
|
118
|
+
to?: Date;
|
|
119
|
+
};
|
|
120
|
+
orderBy?: string;
|
|
121
|
+
limit?: number;
|
|
122
|
+
offset?: number;
|
|
123
|
+
}): Promise<IgniterJobSearchResult[]>;
|
|
124
|
+
searchQueues(filter: {
|
|
125
|
+
name?: string;
|
|
126
|
+
isPaused?: boolean;
|
|
127
|
+
}): Promise<IgniterQueueInfo[]>;
|
|
128
|
+
shutdown(): Promise<void>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export { BullMQAdapter, type BullMQAdapterOptions };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { Redis } from 'ioredis';
|
|
2
|
+
import { I as IgniterJobsAdapter, A as AdapterDispatchParams, a as AdapterScheduleParams, b as IgniterJobInfo, c as IgniterJobStatus, d as IgniterJobLog, e as IgniterQueueInfo, f as IgniterQueueCleanOptions, g as IgniterJobCounts, h as IgniterJobSearchResult, i as IgniterJobEventHandler, j as IgniterJobUnsubscribeFn, k as AdapterWorkerConfig, l as AdapterJobHandler, m as AdapterWorkerHandle } from '../adapter-CcQCatSa.js';
|
|
3
|
+
import '@igniter-js/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @fileoverview BullMQ adapter for @igniter-js/jobs
|
|
7
|
+
* @module @igniter-js/jobs/adapters/bullmq
|
|
8
|
+
*
|
|
9
|
+
* @description
|
|
10
|
+
* Provides BullMQ-based implementation of the IgniterJobsAdapter interface.
|
|
11
|
+
* Requires Redis connection via ioredis.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { BullMQAdapter } from '@igniter-js/jobs/adapters'
|
|
16
|
+
* import Redis from 'ioredis'
|
|
17
|
+
*
|
|
18
|
+
* const redis = new Redis()
|
|
19
|
+
* const adapter = BullMQAdapter.create({ redis })
|
|
20
|
+
*
|
|
21
|
+
* const jobs = IgniterJobs.create<AppContext>()
|
|
22
|
+
* .withAdapter(adapter)
|
|
23
|
+
* .build()
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* BullMQ adapter options.
|
|
29
|
+
*/
|
|
30
|
+
interface BullMQAdapterOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Redis connection (ioredis instance).
|
|
33
|
+
*/
|
|
34
|
+
redis: Redis;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* BullMQ implementation of IgniterJobsAdapter.
|
|
38
|
+
*/
|
|
39
|
+
declare class BullMQAdapter implements IgniterJobsAdapter {
|
|
40
|
+
private readonly redis;
|
|
41
|
+
private readonly queues;
|
|
42
|
+
private readonly workers;
|
|
43
|
+
private readonly queueEvents;
|
|
44
|
+
private BullMQ;
|
|
45
|
+
private constructor();
|
|
46
|
+
/**
|
|
47
|
+
* Create a new BullMQ adapter.
|
|
48
|
+
*
|
|
49
|
+
* @param options - Adapter options with Redis connection
|
|
50
|
+
* @returns A new BullMQAdapter instance
|
|
51
|
+
*/
|
|
52
|
+
static create(options: BullMQAdapterOptions): BullMQAdapter;
|
|
53
|
+
/**
|
|
54
|
+
* Get the underlying Redis client.
|
|
55
|
+
*/
|
|
56
|
+
get client(): Redis;
|
|
57
|
+
/**
|
|
58
|
+
* Lazily load BullMQ module.
|
|
59
|
+
*/
|
|
60
|
+
private getBullMQ;
|
|
61
|
+
/**
|
|
62
|
+
* Get or create a queue instance.
|
|
63
|
+
*/
|
|
64
|
+
private getOrCreateQueue;
|
|
65
|
+
/**
|
|
66
|
+
* Get or create queue events instance.
|
|
67
|
+
*/
|
|
68
|
+
private getQueueEvents;
|
|
69
|
+
/**
|
|
70
|
+
* Convert BullMQ job state to IgniterJobStatus.
|
|
71
|
+
*/
|
|
72
|
+
private mapJobState;
|
|
73
|
+
/**
|
|
74
|
+
* Convert BullMQ job to IgniterJobInfo.
|
|
75
|
+
*/
|
|
76
|
+
private mapJobToInfo;
|
|
77
|
+
dispatch(params: AdapterDispatchParams): Promise<string>;
|
|
78
|
+
schedule(params: AdapterScheduleParams): Promise<string>;
|
|
79
|
+
getJob(queue: string, jobId: string): Promise<IgniterJobInfo | null>;
|
|
80
|
+
getJobState(queue: string, jobId: string): Promise<IgniterJobStatus | null>;
|
|
81
|
+
getJobProgress(queue: string, jobId: string): Promise<number>;
|
|
82
|
+
getJobLogs(queue: string, jobId: string): Promise<IgniterJobLog[]>;
|
|
83
|
+
retryJob(queue: string, jobId: string): Promise<void>;
|
|
84
|
+
removeJob(queue: string, jobId: string): Promise<void>;
|
|
85
|
+
promoteJob(queue: string, jobId: string): Promise<void>;
|
|
86
|
+
moveJob(queue: string, jobId: string, state: 'failed' | 'completed', reason?: string): Promise<void>;
|
|
87
|
+
retryJobs(queue: string, jobIds: string[]): Promise<void>;
|
|
88
|
+
removeJobs(queue: string, jobIds: string[]): Promise<void>;
|
|
89
|
+
getQueue(queue: string): Promise<IgniterQueueInfo>;
|
|
90
|
+
pauseQueue(queue: string): Promise<void>;
|
|
91
|
+
resumeQueue(queue: string): Promise<void>;
|
|
92
|
+
drainQueue(queue: string): Promise<number>;
|
|
93
|
+
cleanQueue(queue: string, options: IgniterQueueCleanOptions): Promise<number>;
|
|
94
|
+
obliterateQueue(queue: string, options?: {
|
|
95
|
+
force?: boolean;
|
|
96
|
+
}): Promise<void>;
|
|
97
|
+
retryAllFailed(queue: string): Promise<number>;
|
|
98
|
+
getJobCounts(queue: string): Promise<IgniterJobCounts>;
|
|
99
|
+
listJobs(queue: string, options?: {
|
|
100
|
+
status?: IgniterJobStatus[];
|
|
101
|
+
start?: number;
|
|
102
|
+
end?: number;
|
|
103
|
+
}): Promise<IgniterJobSearchResult[]>;
|
|
104
|
+
pauseJobType(queue: string, jobName: string): Promise<void>;
|
|
105
|
+
resumeJobType(queue: string, jobName: string): Promise<void>;
|
|
106
|
+
private config?;
|
|
107
|
+
subscribe(pattern: string, handler: IgniterJobEventHandler): Promise<IgniterJobUnsubscribeFn>;
|
|
108
|
+
private matchesPattern;
|
|
109
|
+
createWorker(config: AdapterWorkerConfig, handler: AdapterJobHandler): Promise<AdapterWorkerHandle>;
|
|
110
|
+
searchJobs(filter: {
|
|
111
|
+
status?: IgniterJobStatus[];
|
|
112
|
+
queue?: string;
|
|
113
|
+
jobName?: string;
|
|
114
|
+
scopeId?: string;
|
|
115
|
+
actorId?: string;
|
|
116
|
+
dateRange?: {
|
|
117
|
+
from?: Date;
|
|
118
|
+
to?: Date;
|
|
119
|
+
};
|
|
120
|
+
orderBy?: string;
|
|
121
|
+
limit?: number;
|
|
122
|
+
offset?: number;
|
|
123
|
+
}): Promise<IgniterJobSearchResult[]>;
|
|
124
|
+
searchQueues(filter: {
|
|
125
|
+
name?: string;
|
|
126
|
+
isPaused?: boolean;
|
|
127
|
+
}): Promise<IgniterQueueInfo[]>;
|
|
128
|
+
shutdown(): Promise<void>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export { BullMQAdapter, type BullMQAdapterOptions };
|