@happyvertical/jobs 0.80.0 → 0.80.2
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/adapters/bull.js +343 -346
- package/dist/adapters/bull.js.map +1 -1
- package/dist/adapters/bullmq.js +351 -388
- package/dist/adapters/bullmq.js.map +1 -1
- package/dist/adapters/cloud-tasks.js +307 -333
- package/dist/adapters/cloud-tasks.js.map +1 -1
- package/dist/adapters/postgres.js +288 -328
- package/dist/adapters/postgres.js.map +1 -1
- package/dist/adapters/sqlite.js +236 -258
- package/dist/adapters/sqlite.js.map +1 -1
- package/dist/adapters/sqs.js +363 -408
- package/dist/adapters/sqs.js.map +1 -1
- package/dist/chunks/base-store-DIasEzL0.js +386 -0
- package/dist/chunks/base-store-DIasEzL0.js.map +1 -0
- package/dist/cli/claude-context.js +17 -17
- package/dist/cli/claude-context.js.map +1 -1
- package/dist/index.js +219 -242
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/dist/chunks/base-store-DlNksWvQ.js +0 -324
- package/dist/chunks/base-store-DlNksWvQ.js.map +0 -1
|
@@ -1,336 +1,310 @@
|
|
|
1
|
+
import { n as priorityToNumber, t as BaseJobStore } from "../chunks/base-store-DIasEzL0.js";
|
|
1
2
|
import { createId } from "@happyvertical/utils";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
case "completed":
|
|
304
|
-
totals.completed++;
|
|
305
|
-
break;
|
|
306
|
-
case "failed":
|
|
307
|
-
totals.failed++;
|
|
308
|
-
break;
|
|
309
|
-
case "cancelled":
|
|
310
|
-
totals.cancelled++;
|
|
311
|
-
break;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
return totals;
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Close the Cloud Tasks client
|
|
318
|
-
*/
|
|
319
|
-
async close() {
|
|
320
|
-
if (this.client) {
|
|
321
|
-
await this.client.close();
|
|
322
|
-
this.client = null;
|
|
323
|
-
}
|
|
324
|
-
this.jobStates.clear();
|
|
325
|
-
this.initialized = false;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
3
|
+
//#region src/adapters/cloud-tasks.ts
|
|
4
|
+
/**
|
|
5
|
+
* Cloud Tasks-based job store implementation
|
|
6
|
+
*
|
|
7
|
+
* Note: Cloud Tasks operates differently from traditional job queues:
|
|
8
|
+
* - Jobs are HTTP tasks sent to your handler URL
|
|
9
|
+
* - No pull-based dequeue (Cloud Tasks pushes to your handler)
|
|
10
|
+
* - Updates are limited (tasks can be deleted but not modified)
|
|
11
|
+
*/
|
|
12
|
+
var CloudTasksJobStore = class extends BaseJobStore {
|
|
13
|
+
config;
|
|
14
|
+
client = null;
|
|
15
|
+
cloudTasksModule = null;
|
|
16
|
+
jobStates = /* @__PURE__ */ new Map();
|
|
17
|
+
constructor(config) {
|
|
18
|
+
super();
|
|
19
|
+
this.config = {
|
|
20
|
+
queuePrefix: "",
|
|
21
|
+
defaultRetry: {
|
|
22
|
+
maxAttempts: 3,
|
|
23
|
+
minBackoff: "1s",
|
|
24
|
+
maxBackoff: "300s"
|
|
25
|
+
},
|
|
26
|
+
...config
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Initialize the store - dynamically imports Google Cloud Tasks
|
|
31
|
+
*/
|
|
32
|
+
async initialize() {
|
|
33
|
+
if (this.initialized) return;
|
|
34
|
+
try {
|
|
35
|
+
this.cloudTasksModule = await import("@google-cloud/tasks");
|
|
36
|
+
} catch {
|
|
37
|
+
throw new Error("Google Cloud Tasks is required for CloudTasksJobStore. Install it with: npm install @google-cloud/tasks");
|
|
38
|
+
}
|
|
39
|
+
this.client = new this.cloudTasksModule.CloudTasksClient();
|
|
40
|
+
this.initialized = true;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get the full queue path
|
|
44
|
+
*/
|
|
45
|
+
getQueuePath(queueName) {
|
|
46
|
+
return `projects/${this.config.projectId}/locations/${this.config.location}/queues/${this.config.queuePrefix}${queueName}`;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get the full task path
|
|
50
|
+
*/
|
|
51
|
+
getTaskPath(queueName, taskId) {
|
|
52
|
+
return `${this.getQueuePath(queueName)}/tasks/${taskId}`;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Enqueue a new job
|
|
56
|
+
*/
|
|
57
|
+
async enqueue(options) {
|
|
58
|
+
if (!this.initialized || !this.client) throw new Error("CloudTasksJobStore not initialized");
|
|
59
|
+
const queueName = options.queue ?? "default";
|
|
60
|
+
const now = /* @__PURE__ */ new Date();
|
|
61
|
+
const jobId = createId();
|
|
62
|
+
const jobData = {
|
|
63
|
+
id: jobId,
|
|
64
|
+
queue: queueName,
|
|
65
|
+
payload: options.payload,
|
|
66
|
+
priority: priorityToNumber(options.priority),
|
|
67
|
+
maxAttempts: options.maxAttempts ?? 3,
|
|
68
|
+
timeout: options.timeout ?? 3e5,
|
|
69
|
+
timeoutBehavior: options.timeoutBehavior ?? "fail",
|
|
70
|
+
retryStrategy: options.retryStrategy && "toConfig" in options.retryStrategy ? options.retryStrategy.toConfig() : options.retryStrategy ?? {
|
|
71
|
+
type: "exponential",
|
|
72
|
+
config: {
|
|
73
|
+
initialDelay: 1e3,
|
|
74
|
+
multiplier: 2
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
createdAt: now.toISOString()
|
|
78
|
+
};
|
|
79
|
+
const task = {
|
|
80
|
+
name: this.getTaskPath(queueName, jobId),
|
|
81
|
+
httpRequest: {
|
|
82
|
+
httpMethod: "POST",
|
|
83
|
+
url: this.config.handlerUrl,
|
|
84
|
+
headers: { "Content-Type": "application/json" },
|
|
85
|
+
body: Buffer.from(JSON.stringify(jobData)).toString("base64")
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
if (this.config.serviceAccountEmail) task.httpRequest.oidcToken = { serviceAccountEmail: this.config.serviceAccountEmail };
|
|
89
|
+
if (options.runAt && options.runAt > now) task.scheduleTime = {
|
|
90
|
+
seconds: Math.floor(options.runAt.getTime() / 1e3),
|
|
91
|
+
nanos: options.runAt.getTime() % 1e3 * 1e6
|
|
92
|
+
};
|
|
93
|
+
if (options.timeout) task.dispatchDeadline = {
|
|
94
|
+
seconds: Math.floor(options.timeout / 1e3),
|
|
95
|
+
nanos: options.timeout % 1e3 * 1e6
|
|
96
|
+
};
|
|
97
|
+
const [response] = await this.client.createTask({
|
|
98
|
+
parent: this.getQueuePath(queueName),
|
|
99
|
+
task
|
|
100
|
+
});
|
|
101
|
+
const job = {
|
|
102
|
+
id: jobId,
|
|
103
|
+
queue: queueName,
|
|
104
|
+
payload: options.payload,
|
|
105
|
+
status: "pending",
|
|
106
|
+
priority: priorityToNumber(options.priority),
|
|
107
|
+
attempts: 0,
|
|
108
|
+
maxAttempts: options.maxAttempts ?? 3,
|
|
109
|
+
runAt: options.runAt ?? now,
|
|
110
|
+
startedAt: null,
|
|
111
|
+
completedAt: null,
|
|
112
|
+
timeout: options.timeout ?? 3e5,
|
|
113
|
+
timeoutBehavior: options.timeoutBehavior ?? "fail",
|
|
114
|
+
lastError: null,
|
|
115
|
+
resultPointer: null,
|
|
116
|
+
retryStrategy: jobData.retryStrategy,
|
|
117
|
+
workerId: null,
|
|
118
|
+
workerHeartbeat: null,
|
|
119
|
+
createdAt: now,
|
|
120
|
+
updatedAt: now
|
|
121
|
+
};
|
|
122
|
+
this.jobStates.set(jobId, {
|
|
123
|
+
job,
|
|
124
|
+
taskName: response.name ?? void 0
|
|
125
|
+
});
|
|
126
|
+
await this.emitEvent("job.created", job);
|
|
127
|
+
return job;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Dequeue jobs - NOT SUPPORTED in Cloud Tasks
|
|
131
|
+
* Cloud Tasks is push-based; jobs are delivered to your handler URL
|
|
132
|
+
*/
|
|
133
|
+
async dequeue(_queues, _limit, _workerId) {
|
|
134
|
+
throw new Error("Cloud Tasks does not support pull-based dequeue. Jobs are pushed to your handler URL. Use the HTTP handler to receive jobs.");
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Update a job - LIMITED SUPPORT in Cloud Tasks
|
|
138
|
+
*/
|
|
139
|
+
async update(_id, _updates) {
|
|
140
|
+
throw new Error("Cloud Tasks does not support updating tasks after creation. Cancel and recreate the job instead.");
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Get a job by ID
|
|
144
|
+
*/
|
|
145
|
+
async get(id) {
|
|
146
|
+
const state = this.jobStates.get(id);
|
|
147
|
+
if (state) return state.job;
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* List jobs with filtering
|
|
152
|
+
* Note: Only returns jobs from in-memory state
|
|
153
|
+
*/
|
|
154
|
+
async list(filter) {
|
|
155
|
+
const jobs = [];
|
|
156
|
+
const limit = filter.limit ?? 100;
|
|
157
|
+
for (const state of this.jobStates.values()) {
|
|
158
|
+
const job = state.job;
|
|
159
|
+
if (filter.queue && job.queue !== filter.queue) continue;
|
|
160
|
+
if (filter.status) {
|
|
161
|
+
if (!(Array.isArray(filter.status) ? filter.status : [filter.status]).includes(job.status)) continue;
|
|
162
|
+
}
|
|
163
|
+
if (filter.objectType && job.payload.objectType !== filter.objectType) continue;
|
|
164
|
+
if (filter.method && job.payload.method !== filter.method) continue;
|
|
165
|
+
if (filter.createdAfter && job.createdAt < filter.createdAfter) continue;
|
|
166
|
+
if (filter.createdBefore && job.createdAt > filter.createdBefore) continue;
|
|
167
|
+
jobs.push(job);
|
|
168
|
+
if (jobs.length >= limit) break;
|
|
169
|
+
}
|
|
170
|
+
return jobs;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Cancel a job by deleting its Cloud Task
|
|
174
|
+
*/
|
|
175
|
+
async cancel(id) {
|
|
176
|
+
if (!this.initialized || !this.client) throw new Error("CloudTasksJobStore not initialized");
|
|
177
|
+
const state = this.jobStates.get(id);
|
|
178
|
+
if (!state || !state.taskName) throw new Error(`Job ${id} not found`);
|
|
179
|
+
try {
|
|
180
|
+
await this.client.deleteTask({ name: state.taskName });
|
|
181
|
+
} catch (error) {
|
|
182
|
+
if (error.code !== 5) throw error;
|
|
183
|
+
}
|
|
184
|
+
state.job.status = "cancelled";
|
|
185
|
+
state.job.completedAt = /* @__PURE__ */ new Date();
|
|
186
|
+
await this.emitEvent("job.cancelled", state.job);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Mark job as started (called by your handler when it receives the job)
|
|
190
|
+
*/
|
|
191
|
+
async markStarted(id, workerId) {
|
|
192
|
+
const state = this.jobStates.get(id);
|
|
193
|
+
if (!state) throw new Error(`Job ${id} not found`);
|
|
194
|
+
state.job.status = "running";
|
|
195
|
+
state.job.workerId = workerId;
|
|
196
|
+
state.job.startedAt = /* @__PURE__ */ new Date();
|
|
197
|
+
state.job.attempts++;
|
|
198
|
+
await this.emitEvent("job.started", state.job);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Mark job as completed (called by your handler after successful execution)
|
|
202
|
+
*/
|
|
203
|
+
async markCompleted(id, resultPointer) {
|
|
204
|
+
const state = this.jobStates.get(id);
|
|
205
|
+
if (!state) throw new Error(`Job ${id} not found`);
|
|
206
|
+
state.job.status = "completed";
|
|
207
|
+
state.job.completedAt = /* @__PURE__ */ new Date();
|
|
208
|
+
state.job.resultPointer = resultPointer ?? null;
|
|
209
|
+
await this.emitEvent("job.completed", state.job, { resultPointer });
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Mark job as failed (called by your handler after failed execution)
|
|
213
|
+
*/
|
|
214
|
+
async markFailed(id, error) {
|
|
215
|
+
const state = this.jobStates.get(id);
|
|
216
|
+
if (!state) throw new Error(`Job ${id} not found`);
|
|
217
|
+
state.job.status = "failed";
|
|
218
|
+
state.job.completedAt = /* @__PURE__ */ new Date();
|
|
219
|
+
state.job.lastError = error;
|
|
220
|
+
await this.emitEvent("job.failed", state.job, { error });
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Clean up old jobs from in-memory state
|
|
224
|
+
*/
|
|
225
|
+
async cleanup(options) {
|
|
226
|
+
let cleaned = 0;
|
|
227
|
+
for (const [id, state] of this.jobStates) {
|
|
228
|
+
const { job } = state;
|
|
229
|
+
if (options.completedBefore && job.status === "completed" && job.completedAt && job.completedAt < options.completedBefore) {
|
|
230
|
+
this.jobStates.delete(id);
|
|
231
|
+
cleaned++;
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
if (options.failedBefore && job.status === "failed" && job.completedAt && job.completedAt < options.failedBefore) {
|
|
235
|
+
this.jobStates.delete(id);
|
|
236
|
+
cleaned++;
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
if (options.cancelledBefore && job.status === "cancelled" && job.completedAt && job.completedAt < options.cancelledBefore) {
|
|
240
|
+
this.jobStates.delete(id);
|
|
241
|
+
cleaned++;
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
if (options.limit && cleaned >= options.limit) break;
|
|
245
|
+
}
|
|
246
|
+
return cleaned;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Update worker heartbeat - stored in memory only
|
|
250
|
+
*/
|
|
251
|
+
async heartbeat(jobId, _workerId) {
|
|
252
|
+
const state = this.jobStates.get(jobId);
|
|
253
|
+
if (state) state.job.workerHeartbeat = /* @__PURE__ */ new Date();
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Get queue statistics from in-memory state
|
|
257
|
+
*/
|
|
258
|
+
async stats(queue) {
|
|
259
|
+
const totals = {
|
|
260
|
+
pending: 0,
|
|
261
|
+
running: 0,
|
|
262
|
+
completed: 0,
|
|
263
|
+
failed: 0,
|
|
264
|
+
cancelled: 0,
|
|
265
|
+
avgDuration: null
|
|
266
|
+
};
|
|
267
|
+
for (const state of this.jobStates.values()) {
|
|
268
|
+
if (queue && state.job.queue !== queue) continue;
|
|
269
|
+
switch (state.job.status) {
|
|
270
|
+
case "pending":
|
|
271
|
+
totals.pending++;
|
|
272
|
+
break;
|
|
273
|
+
case "running":
|
|
274
|
+
totals.running++;
|
|
275
|
+
break;
|
|
276
|
+
case "completed":
|
|
277
|
+
totals.completed++;
|
|
278
|
+
break;
|
|
279
|
+
case "failed":
|
|
280
|
+
totals.failed++;
|
|
281
|
+
break;
|
|
282
|
+
case "cancelled":
|
|
283
|
+
totals.cancelled++;
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return totals;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Close the Cloud Tasks client
|
|
291
|
+
*/
|
|
292
|
+
async close() {
|
|
293
|
+
if (this.client) {
|
|
294
|
+
await this.client.close();
|
|
295
|
+
this.client = null;
|
|
296
|
+
}
|
|
297
|
+
this.jobStates.clear();
|
|
298
|
+
this.initialized = false;
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
/**
|
|
302
|
+
* Create a Cloud Tasks job store instance
|
|
303
|
+
*/
|
|
328
304
|
function createCloudTasksJobStore(config) {
|
|
329
|
-
|
|
305
|
+
return new CloudTasksJobStore(config);
|
|
330
306
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
};
|
|
336
|
-
//# sourceMappingURL=cloud-tasks.js.map
|
|
307
|
+
//#endregion
|
|
308
|
+
export { CloudTasksJobStore, CloudTasksJobStore as default, createCloudTasksJobStore };
|
|
309
|
+
|
|
310
|
+
//# sourceMappingURL=cloud-tasks.js.map
|