@orchestr-sh/orchestr 1.7.3 → 1.8.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/dist/Console/Commands/MakeJobCommand.d.ts +20 -0
- package/dist/Console/Commands/MakeJobCommand.d.ts.map +1 -0
- package/dist/Console/Commands/MakeJobCommand.js +165 -0
- package/dist/Console/Commands/MakeJobCommand.js.map +1 -0
- package/dist/Console/Commands/QueueBatchesTableCommand.d.ts +17 -0
- package/dist/Console/Commands/QueueBatchesTableCommand.d.ts.map +1 -0
- package/dist/Console/Commands/QueueBatchesTableCommand.js +92 -0
- package/dist/Console/Commands/QueueBatchesTableCommand.js.map +1 -0
- package/dist/Console/Commands/QueueClearCommand.d.ts +16 -0
- package/dist/Console/Commands/QueueClearCommand.d.ts.map +1 -0
- package/dist/Console/Commands/QueueClearCommand.js +29 -0
- package/dist/Console/Commands/QueueClearCommand.js.map +1 -0
- package/dist/Console/Commands/QueueFailedCommand.d.ts +18 -0
- package/dist/Console/Commands/QueueFailedCommand.d.ts.map +1 -0
- package/dist/Console/Commands/QueueFailedCommand.js +76 -0
- package/dist/Console/Commands/QueueFailedCommand.js.map +1 -0
- package/dist/Console/Commands/QueueFailedTableCommand.d.ts +17 -0
- package/dist/Console/Commands/QueueFailedTableCommand.d.ts.map +1 -0
- package/dist/Console/Commands/QueueFailedTableCommand.js +89 -0
- package/dist/Console/Commands/QueueFailedTableCommand.js.map +1 -0
- package/dist/Console/Commands/QueueFlushCommand.d.ts +18 -0
- package/dist/Console/Commands/QueueFlushCommand.d.ts.map +1 -0
- package/dist/Console/Commands/QueueFlushCommand.js +44 -0
- package/dist/Console/Commands/QueueFlushCommand.js.map +1 -0
- package/dist/Console/Commands/QueueForgetCommand.d.ts +18 -0
- package/dist/Console/Commands/QueueForgetCommand.d.ts.map +1 -0
- package/dist/Console/Commands/QueueForgetCommand.js +48 -0
- package/dist/Console/Commands/QueueForgetCommand.js.map +1 -0
- package/dist/Console/Commands/QueueMonitorCommand.d.ts +16 -0
- package/dist/Console/Commands/QueueMonitorCommand.d.ts.map +1 -0
- package/dist/Console/Commands/QueueMonitorCommand.js +42 -0
- package/dist/Console/Commands/QueueMonitorCommand.js.map +1 -0
- package/dist/Console/Commands/QueuePruneBatchesCommand.d.ts +16 -0
- package/dist/Console/Commands/QueuePruneBatchesCommand.d.ts.map +1 -0
- package/dist/Console/Commands/QueuePruneBatchesCommand.js +44 -0
- package/dist/Console/Commands/QueuePruneBatchesCommand.js.map +1 -0
- package/dist/Console/Commands/QueuePruneFailedCommand.d.ts +18 -0
- package/dist/Console/Commands/QueuePruneFailedCommand.d.ts.map +1 -0
- package/dist/Console/Commands/QueuePruneFailedCommand.js +39 -0
- package/dist/Console/Commands/QueuePruneFailedCommand.js.map +1 -0
- package/dist/Console/Commands/QueueRestartCommand.d.ts +16 -0
- package/dist/Console/Commands/QueueRestartCommand.d.ts.map +1 -0
- package/dist/Console/Commands/QueueRestartCommand.js +34 -0
- package/dist/Console/Commands/QueueRestartCommand.js.map +1 -0
- package/dist/Console/Commands/QueueRetryCommand.d.ts +20 -0
- package/dist/Console/Commands/QueueRetryCommand.d.ts.map +1 -0
- package/dist/Console/Commands/QueueRetryCommand.js +77 -0
- package/dist/Console/Commands/QueueRetryCommand.js.map +1 -0
- package/dist/Console/Commands/QueueTableCommand.d.ts +17 -0
- package/dist/Console/Commands/QueueTableCommand.d.ts.map +1 -0
- package/dist/Console/Commands/QueueTableCommand.js +89 -0
- package/dist/Console/Commands/QueueTableCommand.js.map +1 -0
- package/dist/Console/Commands/QueueWorkCommand.d.ts +16 -0
- package/dist/Console/Commands/QueueWorkCommand.d.ts.map +1 -0
- package/dist/Console/Commands/QueueWorkCommand.js +51 -0
- package/dist/Console/Commands/QueueWorkCommand.js.map +1 -0
- package/dist/Events/Dispatcher.d.ts.map +1 -1
- package/dist/Events/Dispatcher.js +10 -1
- package/dist/Events/Dispatcher.js.map +1 -1
- package/dist/Facades/Bus.d.ts +62 -0
- package/dist/Facades/Bus.d.ts.map +1 -0
- package/dist/Facades/Bus.js +102 -0
- package/dist/Facades/Bus.js.map +1 -0
- package/dist/Facades/Queue.d.ts +42 -0
- package/dist/Facades/Queue.d.ts.map +1 -0
- package/dist/Facades/Queue.js +71 -0
- package/dist/Facades/Queue.js.map +1 -0
- package/dist/Facades/index.d.ts +2 -0
- package/dist/Facades/index.d.ts.map +1 -1
- package/dist/Facades/index.js +5 -1
- package/dist/Facades/index.js.map +1 -1
- package/dist/Queue/Batching/Batch.d.ts +86 -0
- package/dist/Queue/Batching/Batch.d.ts.map +1 -0
- package/dist/Queue/Batching/Batch.js +170 -0
- package/dist/Queue/Batching/Batch.js.map +1 -0
- package/dist/Queue/Batching/PendingBatch.d.ts +72 -0
- package/dist/Queue/Batching/PendingBatch.d.ts.map +1 -0
- package/dist/Queue/Batching/PendingBatch.js +122 -0
- package/dist/Queue/Batching/PendingBatch.js.map +1 -0
- package/dist/Queue/Batching/index.d.ts +3 -0
- package/dist/Queue/Batching/index.d.ts.map +1 -0
- package/dist/Queue/Batching/index.js +8 -0
- package/dist/Queue/Batching/index.js.map +1 -0
- package/dist/Queue/Concerns/Dispatchable.d.ts +36 -0
- package/dist/Queue/Concerns/Dispatchable.d.ts.map +1 -0
- package/dist/Queue/Concerns/Dispatchable.js +102 -0
- package/dist/Queue/Concerns/Dispatchable.js.map +1 -0
- package/dist/Queue/Contracts/QueueDriver.d.ts +67 -0
- package/dist/Queue/Contracts/QueueDriver.d.ts.map +1 -0
- package/dist/Queue/Contracts/QueueDriver.js +9 -0
- package/dist/Queue/Contracts/QueueDriver.js.map +1 -0
- package/dist/Queue/Contracts/QueueableJob.d.ts +74 -0
- package/dist/Queue/Contracts/QueueableJob.d.ts.map +1 -0
- package/dist/Queue/Contracts/QueueableJob.js +9 -0
- package/dist/Queue/Contracts/QueueableJob.js.map +1 -0
- package/dist/Queue/Contracts/ShouldBeUnique.d.ts +43 -0
- package/dist/Queue/Contracts/ShouldBeUnique.d.ts.map +1 -0
- package/dist/Queue/Contracts/ShouldBeUnique.js +12 -0
- package/dist/Queue/Contracts/ShouldBeUnique.js.map +1 -0
- package/dist/Queue/Drivers/DatabaseDriver.d.ts +39 -0
- package/dist/Queue/Drivers/DatabaseDriver.d.ts.map +1 -0
- package/dist/Queue/Drivers/DatabaseDriver.js +176 -0
- package/dist/Queue/Drivers/DatabaseDriver.js.map +1 -0
- package/dist/Queue/Drivers/NullDriver.d.ts +30 -0
- package/dist/Queue/Drivers/NullDriver.d.ts.map +1 -0
- package/dist/Queue/Drivers/NullDriver.js +57 -0
- package/dist/Queue/Drivers/NullDriver.js.map +1 -0
- package/dist/Queue/Drivers/SyncDriver.d.ts +29 -0
- package/dist/Queue/Drivers/SyncDriver.d.ts.map +1 -0
- package/dist/Queue/Drivers/SyncDriver.js +67 -0
- package/dist/Queue/Drivers/SyncDriver.js.map +1 -0
- package/dist/Queue/Drivers/index.d.ts +4 -0
- package/dist/Queue/Drivers/index.d.ts.map +1 -0
- package/dist/Queue/Drivers/index.js +10 -0
- package/dist/Queue/Drivers/index.js.map +1 -0
- package/dist/Queue/Events/JobExceptionOccurred.d.ts +13 -0
- package/dist/Queue/Events/JobExceptionOccurred.d.ts.map +1 -0
- package/dist/Queue/Events/JobExceptionOccurred.js +20 -0
- package/dist/Queue/Events/JobExceptionOccurred.js.map +1 -0
- package/dist/Queue/Events/JobFailed.d.ts +13 -0
- package/dist/Queue/Events/JobFailed.d.ts.map +1 -0
- package/dist/Queue/Events/JobFailed.js +20 -0
- package/dist/Queue/Events/JobFailed.js.map +1 -0
- package/dist/Queue/Events/JobProcessed.d.ts +12 -0
- package/dist/Queue/Events/JobProcessed.d.ts.map +1 -0
- package/dist/Queue/Events/JobProcessed.js +18 -0
- package/dist/Queue/Events/JobProcessed.js.map +1 -0
- package/dist/Queue/Events/JobProcessing.d.ts +12 -0
- package/dist/Queue/Events/JobProcessing.d.ts.map +1 -0
- package/dist/Queue/Events/JobProcessing.js +18 -0
- package/dist/Queue/Events/JobProcessing.js.map +1 -0
- package/dist/Queue/Events/JobQueued.d.ts +14 -0
- package/dist/Queue/Events/JobQueued.d.ts.map +1 -0
- package/dist/Queue/Events/JobQueued.js +22 -0
- package/dist/Queue/Events/JobQueued.js.map +1 -0
- package/dist/Queue/Events/JobRetryRequested.d.ts +12 -0
- package/dist/Queue/Events/JobRetryRequested.d.ts.map +1 -0
- package/dist/Queue/Events/JobRetryRequested.js +20 -0
- package/dist/Queue/Events/JobRetryRequested.js.map +1 -0
- package/dist/Queue/Events/WorkerStopping.d.ts +11 -0
- package/dist/Queue/Events/WorkerStopping.d.ts.map +1 -0
- package/dist/Queue/Events/WorkerStopping.js +18 -0
- package/dist/Queue/Events/WorkerStopping.js.map +1 -0
- package/dist/Queue/Events/index.d.ts +8 -0
- package/dist/Queue/Events/index.d.ts.map +1 -0
- package/dist/Queue/Events/index.js +18 -0
- package/dist/Queue/Events/index.js.map +1 -0
- package/dist/Queue/Failed/DatabaseFailedJobProvider.d.ts +33 -0
- package/dist/Queue/Failed/DatabaseFailedJobProvider.d.ts.map +1 -0
- package/dist/Queue/Failed/DatabaseFailedJobProvider.js +100 -0
- package/dist/Queue/Failed/DatabaseFailedJobProvider.js.map +1 -0
- package/dist/Queue/Failed/FailedJobProvider.d.ts +42 -0
- package/dist/Queue/Failed/FailedJobProvider.d.ts.map +1 -0
- package/dist/Queue/Failed/FailedJobProvider.js +9 -0
- package/dist/Queue/Failed/FailedJobProvider.js.map +1 -0
- package/dist/Queue/Job.d.ts +194 -0
- package/dist/Queue/Job.d.ts.map +1 -0
- package/dist/Queue/Job.js +286 -0
- package/dist/Queue/Job.js.map +1 -0
- package/dist/Queue/JobPayload.d.ts +37 -0
- package/dist/Queue/JobPayload.d.ts.map +1 -0
- package/dist/Queue/JobPayload.js +46 -0
- package/dist/Queue/JobPayload.js.map +1 -0
- package/dist/Queue/Middleware/JobMiddleware.d.ts +29 -0
- package/dist/Queue/Middleware/JobMiddleware.d.ts.map +1 -0
- package/dist/Queue/Middleware/JobMiddleware.js +21 -0
- package/dist/Queue/Middleware/JobMiddleware.js.map +1 -0
- package/dist/Queue/Middleware/RateLimited.d.ts +56 -0
- package/dist/Queue/Middleware/RateLimited.d.ts.map +1 -0
- package/dist/Queue/Middleware/RateLimited.js +83 -0
- package/dist/Queue/Middleware/RateLimited.js.map +1 -0
- package/dist/Queue/Middleware/ThrottlesExceptions.d.ts +71 -0
- package/dist/Queue/Middleware/ThrottlesExceptions.d.ts.map +1 -0
- package/dist/Queue/Middleware/ThrottlesExceptions.js +119 -0
- package/dist/Queue/Middleware/ThrottlesExceptions.js.map +1 -0
- package/dist/Queue/Middleware/WithoutOverlapping.d.ts +64 -0
- package/dist/Queue/Middleware/WithoutOverlapping.d.ts.map +1 -0
- package/dist/Queue/Middleware/WithoutOverlapping.js +103 -0
- package/dist/Queue/Middleware/WithoutOverlapping.js.map +1 -0
- package/dist/Queue/Middleware/index.d.ts +5 -0
- package/dist/Queue/Middleware/index.d.ts.map +1 -0
- package/dist/Queue/Middleware/index.js +10 -0
- package/dist/Queue/Middleware/index.js.map +1 -0
- package/dist/Queue/PendingChain.d.ts +63 -0
- package/dist/Queue/PendingChain.d.ts.map +1 -0
- package/dist/Queue/PendingChain.js +111 -0
- package/dist/Queue/PendingChain.js.map +1 -0
- package/dist/Queue/PendingDispatch.d.ts +66 -0
- package/dist/Queue/PendingDispatch.d.ts.map +1 -0
- package/dist/Queue/PendingDispatch.js +101 -0
- package/dist/Queue/PendingDispatch.js.map +1 -0
- package/dist/Queue/QueueManager.d.ts +151 -0
- package/dist/Queue/QueueManager.d.ts.map +1 -0
- package/dist/Queue/QueueManager.js +227 -0
- package/dist/Queue/QueueManager.js.map +1 -0
- package/dist/Queue/QueueServiceProvider.d.ts +19 -0
- package/dist/Queue/QueueServiceProvider.d.ts.map +1 -0
- package/dist/Queue/QueueServiceProvider.js +75 -0
- package/dist/Queue/QueueServiceProvider.js.map +1 -0
- package/dist/Queue/Workers/Worker.d.ts +99 -0
- package/dist/Queue/Workers/Worker.d.ts.map +1 -0
- package/dist/Queue/Workers/Worker.js +324 -0
- package/dist/Queue/Workers/Worker.js.map +1 -0
- package/dist/Queue/Workers/WorkerOptions.d.ts +62 -0
- package/dist/Queue/Workers/WorkerOptions.d.ts.map +1 -0
- package/dist/Queue/Workers/WorkerOptions.js +23 -0
- package/dist/Queue/Workers/WorkerOptions.js.map +1 -0
- package/dist/Queue/index.d.ts +41 -0
- package/dist/Queue/index.d.ts.map +1 -0
- package/dist/Queue/index.js +67 -0
- package/dist/Queue/index.js.map +1 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +92 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Batch
|
|
4
|
+
*
|
|
5
|
+
* Represents a batch of jobs being processed.
|
|
6
|
+
* Tracks progress and fires callbacks on completion/failure.
|
|
7
|
+
*
|
|
8
|
+
* Mirrors Laravel's Illuminate\Bus\Batch.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.Batch = void 0;
|
|
12
|
+
const crypto_1 = require("crypto");
|
|
13
|
+
class Batch {
|
|
14
|
+
manager;
|
|
15
|
+
name;
|
|
16
|
+
id;
|
|
17
|
+
createdAt;
|
|
18
|
+
_totalJobs;
|
|
19
|
+
_pendingJobs;
|
|
20
|
+
_failedJobs = 0;
|
|
21
|
+
_failedJobIds = [];
|
|
22
|
+
_cancelled = false;
|
|
23
|
+
_finishedAt = null;
|
|
24
|
+
_options;
|
|
25
|
+
constructor(manager, name, totalJobs, options) {
|
|
26
|
+
this.manager = manager;
|
|
27
|
+
this.name = name;
|
|
28
|
+
this.id = (0, crypto_1.randomUUID)();
|
|
29
|
+
this.createdAt = new Date();
|
|
30
|
+
this._totalJobs = totalJobs;
|
|
31
|
+
this._pendingJobs = totalJobs;
|
|
32
|
+
this._options = options;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get the total number of jobs in the batch
|
|
36
|
+
*/
|
|
37
|
+
get totalJobs() {
|
|
38
|
+
return this._totalJobs;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get the number of pending jobs
|
|
42
|
+
*/
|
|
43
|
+
get pendingJobs() {
|
|
44
|
+
return this._pendingJobs;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get the number of failed jobs
|
|
48
|
+
*/
|
|
49
|
+
get failedJobs() {
|
|
50
|
+
return this._failedJobs;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get the number of processed jobs
|
|
54
|
+
*/
|
|
55
|
+
get processedJobs() {
|
|
56
|
+
return this._totalJobs - this._pendingJobs;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get the batch progress percentage (0-100)
|
|
60
|
+
*/
|
|
61
|
+
progress() {
|
|
62
|
+
if (this._totalJobs === 0)
|
|
63
|
+
return 100;
|
|
64
|
+
return Math.round((this.processedJobs / this._totalJobs) * 100);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Whether the batch has finished
|
|
68
|
+
*/
|
|
69
|
+
finished() {
|
|
70
|
+
return this._pendingJobs === 0;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Whether the batch has been cancelled
|
|
74
|
+
*/
|
|
75
|
+
cancelled() {
|
|
76
|
+
return this._cancelled;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Record a successful job completion
|
|
80
|
+
*/
|
|
81
|
+
async recordSuccessfulJob(jobId) {
|
|
82
|
+
this._pendingJobs = Math.max(0, this._pendingJobs - 1);
|
|
83
|
+
if (this.finished()) {
|
|
84
|
+
await this.fireThenCallbacks();
|
|
85
|
+
await this.fireFinallyCallbacks();
|
|
86
|
+
this._finishedAt = new Date();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Record a failed job
|
|
91
|
+
*/
|
|
92
|
+
async recordFailedJob(jobId, error) {
|
|
93
|
+
this._failedJobs++;
|
|
94
|
+
this._failedJobIds.push(jobId);
|
|
95
|
+
this._pendingJobs = Math.max(0, this._pendingJobs - 1);
|
|
96
|
+
// Fire catch callbacks
|
|
97
|
+
await this.fireCatchCallbacks(error);
|
|
98
|
+
if (!this._options.allowFailures) {
|
|
99
|
+
this.cancel();
|
|
100
|
+
}
|
|
101
|
+
if (this.finished()) {
|
|
102
|
+
await this.fireFinallyCallbacks();
|
|
103
|
+
this._finishedAt = new Date();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Cancel the batch
|
|
108
|
+
*/
|
|
109
|
+
cancel() {
|
|
110
|
+
this._cancelled = true;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Fire the then callbacks
|
|
114
|
+
*/
|
|
115
|
+
async fireThenCallbacks() {
|
|
116
|
+
for (const callback of this._options.thenCallbacks) {
|
|
117
|
+
try {
|
|
118
|
+
await callback(this);
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
console.error('[Queue] Error in batch then callback:', error);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Fire the catch callbacks
|
|
127
|
+
*/
|
|
128
|
+
async fireCatchCallbacks(error) {
|
|
129
|
+
for (const callback of this._options.catchCallbacks) {
|
|
130
|
+
try {
|
|
131
|
+
await callback(this, error);
|
|
132
|
+
}
|
|
133
|
+
catch (callbackError) {
|
|
134
|
+
console.error('[Queue] Error in batch catch callback:', callbackError);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Fire the finally callbacks
|
|
140
|
+
*/
|
|
141
|
+
async fireFinallyCallbacks() {
|
|
142
|
+
for (const callback of this._options.finallyCallbacks) {
|
|
143
|
+
try {
|
|
144
|
+
await callback(this);
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
console.error('[Queue] Error in batch finally callback:', error);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Convert to a plain object for inspection
|
|
153
|
+
*/
|
|
154
|
+
toJSON() {
|
|
155
|
+
return {
|
|
156
|
+
id: this.id,
|
|
157
|
+
name: this.name,
|
|
158
|
+
totalJobs: this._totalJobs,
|
|
159
|
+
pendingJobs: this._pendingJobs,
|
|
160
|
+
failedJobs: this._failedJobs,
|
|
161
|
+
processedJobs: this.processedJobs,
|
|
162
|
+
progress: this.progress(),
|
|
163
|
+
cancelled: this._cancelled,
|
|
164
|
+
createdAt: this.createdAt.toISOString(),
|
|
165
|
+
finishedAt: this._finishedAt?.toISOString() || null,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
exports.Batch = Batch;
|
|
170
|
+
//# sourceMappingURL=Batch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Batch.js","sourceRoot":"","sources":["../../../src/Queue/Batching/Batch.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,mCAAoC;AAUpC,MAAa,KAAK;IAaJ;IACM;IAbF,EAAE,CAAS;IACX,SAAS,CAAO;IAEtB,UAAU,CAAS;IACnB,YAAY,CAAS;IACrB,WAAW,GAAW,CAAC,CAAC;IACxB,aAAa,GAAa,EAAE,CAAC;IAC7B,UAAU,GAAY,KAAK,CAAC;IAC5B,WAAW,GAAgB,IAAI,CAAC;IAChC,QAAQ,CAAe;IAEjC,YACY,OAAqB,EACf,IAAY,EAC5B,SAAiB,EACjB,OAAqB;QAHX,YAAO,GAAP,OAAO,CAAc;QACf,SAAI,GAAJ,IAAI,CAAQ;QAI5B,IAAI,CAAC,EAAE,GAAG,IAAA,mBAAU,GAAE,CAAC;QACvB,IAAI,C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C;YAC9B,CAAC;YAAC,OAAO,aAAa,EAAE,CAAC;gBACvB,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,aAAa,CAAC,CAAC;YACzE,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,oBAAoB;QAClC,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,gBAAgB,EAAE,CAAC;YACtD,IAAI,CAAC;gBACH,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;YACvB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,0CAA0C,EAAE,KAAK,CAAC,CAAC;YACnE,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,UAAU;YAC1B,WAAW,EAAE,IAAI,CAAC,YAAY;YAC9B,UAAU,EAAE,IAAI,CAAC,WAAW;YAC5B,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE;YACzB,SAAS,EAAE,IAAI,CAAC,UAAU;YAC1B,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE;YACvC,UAAU,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,IAAI;SACpD,CAAC;IACJ,CAAC;CACF;AA5KD,sBA4KC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PendingBatch
|
|
3
|
+
*
|
|
4
|
+
* Fluent builder for creating a batch of jobs.
|
|
5
|
+
* Jobs in a batch can run concurrently, with callbacks
|
|
6
|
+
* for progress, completion, and failure.
|
|
7
|
+
*
|
|
8
|
+
* Mirrors Laravel's Illuminate\Bus\PendingBatch.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const batch = await Bus.batch([
|
|
13
|
+
* new ImportCSVRow(1),
|
|
14
|
+
* new ImportCSVRow(2),
|
|
15
|
+
* new ImportCSVRow(3),
|
|
16
|
+
* ])
|
|
17
|
+
* .name('Import CSV')
|
|
18
|
+
* .then((batch) => console.log('All done!'))
|
|
19
|
+
* .catch((batch, error) => console.error('Failed:', error))
|
|
20
|
+
* .finally((batch) => console.log('Batch finished'))
|
|
21
|
+
* .onQueue('imports')
|
|
22
|
+
* .dispatch();
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
import type { Job } from '../Job';
|
|
26
|
+
import type { Application } from '../../Foundation/Application';
|
|
27
|
+
import { Batch } from './Batch';
|
|
28
|
+
export declare class PendingBatch {
|
|
29
|
+
protected app: Application;
|
|
30
|
+
protected jobs: Job[];
|
|
31
|
+
protected _name: string;
|
|
32
|
+
protected _connection?: string;
|
|
33
|
+
protected _queue?: string;
|
|
34
|
+
protected _thenCallbacks: Array<(batch: Batch) => void | Promise<void>>;
|
|
35
|
+
protected _catchCallbacks: Array<(batch: Batch, error: Error) => void | Promise<void>>;
|
|
36
|
+
protected _finallyCallbacks: Array<(batch: Batch) => void | Promise<void>>;
|
|
37
|
+
protected _allowFailures: boolean;
|
|
38
|
+
constructor(app: Application, jobs: Job[]);
|
|
39
|
+
/**
|
|
40
|
+
* Set the name for the batch
|
|
41
|
+
*/
|
|
42
|
+
name(name: string): this;
|
|
43
|
+
/**
|
|
44
|
+
* Set the connection for all jobs in the batch
|
|
45
|
+
*/
|
|
46
|
+
onConnection(connection: string): this;
|
|
47
|
+
/**
|
|
48
|
+
* Set the queue for all jobs in the batch
|
|
49
|
+
*/
|
|
50
|
+
onQueue(queue: string): this;
|
|
51
|
+
/**
|
|
52
|
+
* Register a callback for when all jobs in the batch complete
|
|
53
|
+
*/
|
|
54
|
+
then(callback: (batch: Batch) => void | Promise<void>): this;
|
|
55
|
+
/**
|
|
56
|
+
* Register a callback for when a job in the batch fails
|
|
57
|
+
*/
|
|
58
|
+
catch(callback: (batch: Batch, error: Error) => void | Promise<void>): this;
|
|
59
|
+
/**
|
|
60
|
+
* Register a callback for when the batch finishes (success or failure)
|
|
61
|
+
*/
|
|
62
|
+
finally(callback: (batch: Batch) => void | Promise<void>): this;
|
|
63
|
+
/**
|
|
64
|
+
* Allow the batch to continue processing even if a job fails
|
|
65
|
+
*/
|
|
66
|
+
allowFailures(allow?: boolean): this;
|
|
67
|
+
/**
|
|
68
|
+
* Dispatch the batch
|
|
69
|
+
*/
|
|
70
|
+
dispatch(): Promise<Batch>;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=PendingBatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PendingBatch.d.ts","sourceRoot":"","sources":["../../../src/Queue/Batching/PendingBatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,qBAAa,YAAY;IAUrB,SAAS,CAAC,GAAG,EAAE,WAAW;IAC1B,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE;IAVvB,SAAS,CAAC,KAAK,EAAE,MAAM,CAAM;IAC7B,SAAS,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC/B,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAM;IAC7E,SAAS,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAM;IAC5F,SAAS,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAM;IAChF,SAAS,CAAC,cAAc,EAAE,OAAO,CAAS;gBAG9B,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,GAAG,EAAE;IAGvB;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKxB;;OAEG;IACH,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAKtC;;OAEG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK5B;;OAEG;IACH,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAK5D;;OAEG;IACH,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAK3E;;OAEG;IACH,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAK/D;;OAEG;IACH,aAAa,CAAC,KAAK,GAAE,OAAc,GAAG,IAAI;IAK1C;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,KAAK,CAAC;CAkCjC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PendingBatch
|
|
4
|
+
*
|
|
5
|
+
* Fluent builder for creating a batch of jobs.
|
|
6
|
+
* Jobs in a batch can run concurrently, with callbacks
|
|
7
|
+
* for progress, completion, and failure.
|
|
8
|
+
*
|
|
9
|
+
* Mirrors Laravel's Illuminate\Bus\PendingBatch.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const batch = await Bus.batch([
|
|
14
|
+
* new ImportCSVRow(1),
|
|
15
|
+
* new ImportCSVRow(2),
|
|
16
|
+
* new ImportCSVRow(3),
|
|
17
|
+
* ])
|
|
18
|
+
* .name('Import CSV')
|
|
19
|
+
* .then((batch) => console.log('All done!'))
|
|
20
|
+
* .catch((batch, error) => console.error('Failed:', error))
|
|
21
|
+
* .finally((batch) => console.log('Batch finished'))
|
|
22
|
+
* .onQueue('imports')
|
|
23
|
+
* .dispatch();
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.PendingBatch = void 0;
|
|
28
|
+
const Batch_1 = require("./Batch");
|
|
29
|
+
class PendingBatch {
|
|
30
|
+
app;
|
|
31
|
+
jobs;
|
|
32
|
+
_name = '';
|
|
33
|
+
_connection;
|
|
34
|
+
_queue;
|
|
35
|
+
_thenCallbacks = [];
|
|
36
|
+
_catchCallbacks = [];
|
|
37
|
+
_finallyCallbacks = [];
|
|
38
|
+
_allowFailures = false;
|
|
39
|
+
constructor(app, jobs) {
|
|
40
|
+
this.app = app;
|
|
41
|
+
this.jobs = jobs;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Set the name for the batch
|
|
45
|
+
*/
|
|
46
|
+
name(name) {
|
|
47
|
+
this._name = name;
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Set the connection for all jobs in the batch
|
|
52
|
+
*/
|
|
53
|
+
onConnection(connection) {
|
|
54
|
+
this._connection = connection;
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Set the queue for all jobs in the batch
|
|
59
|
+
*/
|
|
60
|
+
onQueue(queue) {
|
|
61
|
+
this._queue = queue;
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Register a callback for when all jobs in the batch complete
|
|
66
|
+
*/
|
|
67
|
+
then(callback) {
|
|
68
|
+
this._thenCallbacks.push(callback);
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Register a callback for when a job in the batch fails
|
|
73
|
+
*/
|
|
74
|
+
catch(callback) {
|
|
75
|
+
this._catchCallbacks.push(callback);
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Register a callback for when the batch finishes (success or failure)
|
|
80
|
+
*/
|
|
81
|
+
finally(callback) {
|
|
82
|
+
this._finallyCallbacks.push(callback);
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Allow the batch to continue processing even if a job fails
|
|
87
|
+
*/
|
|
88
|
+
allowFailures(allow = true) {
|
|
89
|
+
this._allowFailures = allow;
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Dispatch the batch
|
|
94
|
+
*/
|
|
95
|
+
async dispatch() {
|
|
96
|
+
const manager = this.app.make('queue');
|
|
97
|
+
// Apply connection/queue to all jobs
|
|
98
|
+
for (const job of this.jobs) {
|
|
99
|
+
if (this._connection) {
|
|
100
|
+
job.connection = this._connection;
|
|
101
|
+
}
|
|
102
|
+
if (this._queue) {
|
|
103
|
+
job.queue = this._queue;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// Create batch instance
|
|
107
|
+
const batch = new Batch_1.Batch(manager, this._name, this.jobs.length, {
|
|
108
|
+
thenCallbacks: this._thenCallbacks,
|
|
109
|
+
catchCallbacks: this._catchCallbacks,
|
|
110
|
+
finallyCallbacks: this._finallyCallbacks,
|
|
111
|
+
allowFailures: this._allowFailures,
|
|
112
|
+
});
|
|
113
|
+
// Dispatch all jobs with batch metadata
|
|
114
|
+
for (const job of this.jobs) {
|
|
115
|
+
job._batchId = batch.id;
|
|
116
|
+
await manager.dispatch(job);
|
|
117
|
+
}
|
|
118
|
+
return batch;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.PendingBatch = PendingBatch;
|
|
122
|
+
//# sourceMappingURL=PendingBatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PendingBatch.js","sourceRoot":"","sources":["../../../src/Queue/Batching/PendingBatch.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAKH,mCAAgC;AAEhC,MAAa,YAAY;IAUX;IACA;IAVF,KAAK,GAAW,EAAE,CAAC;IACnB,WAAW,CAAU;IACrB,MAAM,CAAU;IAChB,cAAc,GAAkD,EAAE,CAAC;IACnE,eAAe,GAAgE,EAAE,CAAC;IAClF,iBAAiB,GAAkD,EAAE,CAAC;IACtE,cAAc,GAAY,KAAK,CAAC;IAE1C,YACY,GAAgB,EAChB,IAAW;QADX,QAAG,GAAH,GAAG,CAAa;QAChB,SAAI,GAAJ,IAAI,CAAO;IACpB,CAAC;IAEJ;;OAEG;IACH,IAAI,CAAC,IAAY;QACf,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,UAAkB;QAC7B,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,KAAa;QACnB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,QAAgD;QACnD,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAA8D;QAClE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;I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|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Queue/Batching/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PendingBatch = exports.Batch = void 0;
|
|
4
|
+
var Batch_1 = require("./Batch");
|
|
5
|
+
Object.defineProperty(exports, "Batch", { enumerable: true, get: function () { return Batch_1.Batch; } });
|
|
6
|
+
var PendingBatch_1 = require("./PendingBatch");
|
|
7
|
+
Object.defineProperty(exports, "PendingBatch", { enumerable: true, get: function () { return PendingBatch_1.PendingBatch; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Queue/Batching/index.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,+CAA8C;AAArC,4GAAA,YAAY,OAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dispatchable Concern for Jobs
|
|
3
|
+
*
|
|
4
|
+
* Provides static dispatch methods for Job classes.
|
|
5
|
+
* Similar to the Event Dispatchable mixin, but for queue jobs.
|
|
6
|
+
*/
|
|
7
|
+
import { PendingDispatch } from '../PendingDispatch';
|
|
8
|
+
export declare class JobDispatchable {
|
|
9
|
+
/**
|
|
10
|
+
* Dispatch the job with the given arguments
|
|
11
|
+
*
|
|
12
|
+
* @returns PendingDispatch for fluent configuration
|
|
13
|
+
*/
|
|
14
|
+
static dispatch(...args: any[]): PendingDispatch;
|
|
15
|
+
/**
|
|
16
|
+
* Dispatch the job synchronously (bypass queue)
|
|
17
|
+
*/
|
|
18
|
+
static dispatchSync(...args: any[]): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Dispatch the job if the given condition is true
|
|
21
|
+
*/
|
|
22
|
+
static dispatchIf(condition: boolean | (() => boolean), ...args: any[]): PendingDispatch | null;
|
|
23
|
+
/**
|
|
24
|
+
* Dispatch the job unless the given condition is true
|
|
25
|
+
*/
|
|
26
|
+
static dispatchUnless(condition: boolean | (() => boolean), ...args: any[]): PendingDispatch | null;
|
|
27
|
+
/**
|
|
28
|
+
* Dispatch the job after the response is sent to the browser
|
|
29
|
+
*/
|
|
30
|
+
static dispatchAfterResponse(...args: any[]): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Apply JobDispatchable mixin to a Job class
|
|
34
|
+
*/
|
|
35
|
+
export declare function applyJobDispatchable(jobClass: any): void;
|
|
36
|
+
//# sourceMappingURL=Dispatchable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dispatchable.d.ts","sourceRoot":"","sources":["../../../src/Queue/Concerns/Dispatchable.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,qBAAa,eAAe;IAC1B;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,eAAe;IAWhD;;OAEG;WACU,YAAY,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAWxD;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,eAAe,GAAG,IAAI;IAU/F;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,eAAe,GAAG,IAAI;IAUnG;;OAEG;IACH,MAAM,CAAC,qBAAqB,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;CAkBnD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI,CAmBxD"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Dispatchable Concern for Jobs
|
|
4
|
+
*
|
|
5
|
+
* Provides static dispatch methods for Job classes.
|
|
6
|
+
* Similar to the Event Dispatchable mixin, but for queue jobs.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.JobDispatchable = void 0;
|
|
10
|
+
exports.applyJobDispatchable = applyJobDispatchable;
|
|
11
|
+
const Facade_1 = require("../../Support/Facade");
|
|
12
|
+
const PendingDispatch_1 = require("../PendingDispatch");
|
|
13
|
+
class JobDispatchable {
|
|
14
|
+
/**
|
|
15
|
+
* Dispatch the job with the given arguments
|
|
16
|
+
*
|
|
17
|
+
* @returns PendingDispatch for fluent configuration
|
|
18
|
+
*/
|
|
19
|
+
static dispatch(...args) {
|
|
20
|
+
const app = Facade_1.Facade.getFacadeApplication();
|
|
21
|
+
if (!app) {
|
|
22
|
+
throw new Error('Application not initialized. Cannot dispatch job.');
|
|
23
|
+
}
|
|
24
|
+
const manager = app.make('queue');
|
|
25
|
+
const instance = new this(...args);
|
|
26
|
+
return new PendingDispatch_1.PendingDispatch(manager, instance);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Dispatch the job synchronously (bypass queue)
|
|
30
|
+
*/
|
|
31
|
+
static async dispatchSync(...args) {
|
|
32
|
+
const app = Facade_1.Facade.getFacadeApplication();
|
|
33
|
+
if (!app) {
|
|
34
|
+
throw new Error('Application not initialized. Cannot dispatch job.');
|
|
35
|
+
}
|
|
36
|
+
const manager = app.make('queue');
|
|
37
|
+
const instance = new this(...args);
|
|
38
|
+
await manager.dispatchSync(instance);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Dispatch the job if the given condition is true
|
|
42
|
+
*/
|
|
43
|
+
static dispatchIf(condition, ...args) {
|
|
44
|
+
const shouldDispatch = typeof condition === 'function' ? condition() : condition;
|
|
45
|
+
if (shouldDispatch) {
|
|
46
|
+
return this.dispatch(...args);
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Dispatch the job unless the given condition is true
|
|
52
|
+
*/
|
|
53
|
+
static dispatchUnless(condition, ...args) {
|
|
54
|
+
const shouldNotDispatch = typeof condition === 'function' ? condition() : condition;
|
|
55
|
+
if (!shouldNotDispatch) {
|
|
56
|
+
return this.dispatch(...args);
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Dispatch the job after the response is sent to the browser
|
|
62
|
+
*/
|
|
63
|
+
static dispatchAfterResponse(...args) {
|
|
64
|
+
const app = Facade_1.Facade.getFacadeApplication();
|
|
65
|
+
if (!app) {
|
|
66
|
+
throw new Error('Application not initialized. Cannot dispatch job.');
|
|
67
|
+
}
|
|
68
|
+
const manager = app.make('queue');
|
|
69
|
+
const instance = new this(...args);
|
|
70
|
+
// Use setImmediate/nextTick to execute after the current response
|
|
71
|
+
setImmediate(async () => {
|
|
72
|
+
try {
|
|
73
|
+
await manager.dispatchSync(instance);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.error(`[Queue] Failed to dispatch after response: ${instance.displayName()}`, error);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.JobDispatchable = JobDispatchable;
|
|
82
|
+
/**
|
|
83
|
+
* Apply JobDispatchable mixin to a Job class
|
|
84
|
+
*/
|
|
85
|
+
function applyJobDispatchable(jobClass) {
|
|
86
|
+
const staticMethods = Object.getOwnPropertyNames(JobDispatchable);
|
|
87
|
+
for (const name of staticMethods) {
|
|
88
|
+
if (name === 'constructor' || name === 'prototype' || name === 'length' || name === 'name') {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const descriptor = Object.getOwnPropertyDescriptor(JobDispatchable, name);
|
|
92
|
+
if (descriptor) {
|
|
93
|
+
Object.defineProperty(jobClass, name, {
|
|
94
|
+
value: descriptor.value,
|
|
95
|
+
enumerable: false,
|
|
96
|
+
configurable: true,
|
|
97
|
+
writable: true,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=Dispatchable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dispatchable.js","sourceRoot":"","sources":["../../../src/Queue/Concerns/Dispatchable.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAyFH,oDAmBC;AA1GD,iDAA8C;AAC9C,wDAAqD;AAGrD,MAAa,eAAe;IAC1B;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAW;QAC5B,MAAM,GAAG,GAAG,eAAM,CAAC,oBAAoB,EAAE,CAAC;QAC1C,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;QACvE,CAAC;QAED,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,CAAe,OAAO,CAAC,CAAC;QAChD,MAAM,QAAQ,GAAG,IAAK,IAAY,CAAC,GAAG,IAAI,CAAC,CAAC;QAC5C,OAAO,IAAI,iCAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,IAAW;QACtC,MAAM,GAAG,GAAG,eAAM,CAAC,oBAAoB,EAAE,CAAC;QAC1C,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAA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K,IAAI,EAAE;YACtB,IAAI,CAAC;gBACH,MAAM,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;YACvC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,8CAA8C,QAAQ,CAAC,WAAW,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;YAC/F,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA9ED,0CA8EC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAC,QAAa;IAChD,MAAM,aAAa,GAAG,MAAM,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC;IAElE,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;QACjC,IAAI,IAAI,KAAK,aAAa,IAAI,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YAC3F,SAAS;QACX,CAAC;QAED,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QAE1E,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE;gBACpC,KAAK,EAAE,UAAU,CAAC,KAAK;gBACvB,UAAU,EAAE,KAAK;gBACjB,YAAY,EAAE,IAAI;gBAClB,QAAQ,EAAE,IAAI;aACf,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QueueDriver Contract
|
|
3
|
+
*
|
|
4
|
+
* Defines the interface for queue driver implementations.
|
|
5
|
+
* Mirrors Laravel's Illuminate\Contracts\Queue\Queue interface.
|
|
6
|
+
*/
|
|
7
|
+
import type { Job } from '../Job';
|
|
8
|
+
export interface QueueDriverJob {
|
|
9
|
+
id: string;
|
|
10
|
+
queue: string;
|
|
11
|
+
payload: string;
|
|
12
|
+
attempts: number;
|
|
13
|
+
reservedAt: number | null;
|
|
14
|
+
availableAt: number;
|
|
15
|
+
createdAt: number;
|
|
16
|
+
}
|
|
17
|
+
export interface QueueDriver {
|
|
18
|
+
/**
|
|
19
|
+
* Get the size of the queue
|
|
20
|
+
*/
|
|
21
|
+
size(queue?: string): Promise<number>;
|
|
22
|
+
/**
|
|
23
|
+
* Push a new job onto the queue
|
|
24
|
+
*/
|
|
25
|
+
push(job: Job, queue?: string): Promise<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Push a raw payload onto the queue
|
|
28
|
+
*/
|
|
29
|
+
pushRaw(payload: string, queue?: string, options?: Record<string, any>): Promise<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Push a new job onto the queue after a delay
|
|
32
|
+
*/
|
|
33
|
+
later(delay: number | Date, job: Job, queue?: string): Promise<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Push an array of jobs onto the queue
|
|
36
|
+
*/
|
|
37
|
+
bulk(jobs: Job[], queue?: string): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Pop the next job off of the queue
|
|
40
|
+
*/
|
|
41
|
+
pop(queue?: string): Promise<QueueDriverJob | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Release a reserved job back onto the queue
|
|
44
|
+
*/
|
|
45
|
+
release(id: string, delay?: number): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Delete a reserved job
|
|
48
|
+
*/
|
|
49
|
+
delete(id: string): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Delete all of the jobs from the queue
|
|
52
|
+
*/
|
|
53
|
+
clear(queue?: string): Promise<number>;
|
|
54
|
+
/**
|
|
55
|
+
* Get the connection name for the queue
|
|
56
|
+
*/
|
|
57
|
+
getConnectionName(): string;
|
|
58
|
+
/**
|
|
59
|
+
* Set the connection name for the queue
|
|
60
|
+
*/
|
|
61
|
+
setConnectionName(name: string): void;
|
|
62
|
+
/**
|
|
63
|
+
* Get the default queue name
|
|
64
|
+
*/
|
|
65
|
+
getQueue(queue?: string): string;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=QueueDriver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueueDriver.d.ts","sourceRoot":"","sources":["../../../src/Queue/Contracts/QueueDriver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAElC,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEtC;;OAEG;IACH,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEhD;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEzF;;OAEG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEvE;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjD;;OAEG;IACH,GAAG,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAEpD;;OAEG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnD;;OAEG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAElC;;OAEG;IACH,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEvC;;OAEG;IACH,iBAAiB,IAAI,MAAM,CAAC;IAE5B;;OAEG;IACH,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtC;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAClC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* QueueDriver Contract
|
|
4
|
+
*
|
|
5
|
+
* Defines the interface for queue driver implementations.
|
|
6
|
+
* Mirrors Laravel's Illuminate\Contracts\Queue\Queue interface.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
//# sourceMappingURL=QueueDriver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueueDriver.js","sourceRoot":"","sources":["../../../src/Queue/Contracts/QueueDriver.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
|