aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue/job-queue.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/job-queue/job-queue.ts')
-rw-r--r--server/lib/job-queue/job-queue.ts27
1 files changed, 19 insertions, 8 deletions
diff --git a/server/lib/job-queue/job-queue.ts b/server/lib/job-queue/job-queue.ts
index 50d732beb..386d20103 100644
--- a/server/lib/job-queue/job-queue.ts
+++ b/server/lib/job-queue/job-queue.ts
@@ -325,10 +325,8 @@ class JobQueue {
325 if (!job) continue 325 if (!job) continue
326 326
327 lastJob = { 327 lastJob = {
328 name: 'job', 328 ...this.buildJobFlowOption(job),
329 data: job.payload, 329
330 queueName: job.type,
331 opts: this.buildJobOptions(job.type as JobType, pick(job, [ 'priority', 'delay' ])),
332 children: lastJob 330 children: lastJob
333 ? [ lastJob ] 331 ? [ lastJob ]
334 : [] 332 : []
@@ -338,6 +336,23 @@ class JobQueue {
338 return this.flowProducer.add(lastJob) 336 return this.flowProducer.add(lastJob)
339 } 337 }
340 338
339 async createJobWithChildren (parent: CreateJobArgument & CreateJobOptions, children: (CreateJobArgument & CreateJobOptions)[]) {
340 return this.flowProducer.add({
341 ...this.buildJobFlowOption(parent),
342
343 children: children.map(c => this.buildJobFlowOption(c))
344 })
345 }
346
347 private buildJobFlowOption (job: CreateJobArgument & CreateJobOptions) {
348 return {
349 name: 'job',
350 data: job.payload,
351 queueName: job.type,
352 opts: this.buildJobOptions(job.type as JobType, pick(job, [ 'priority', 'delay' ]))
353 }
354 }
355
341 private buildJobOptions (type: JobType, options: CreateJobOptions = {}): JobsOptions { 356 private buildJobOptions (type: JobType, options: CreateJobOptions = {}): JobsOptions {
342 return { 357 return {
343 backoff: { delay: 60 * 1000, type: 'exponential' }, 358 backoff: { delay: 60 * 1000, type: 'exponential' },
@@ -425,10 +440,6 @@ class JobQueue {
425 } 440 }
426 } 441 }
427 442
428 waitJob (job: Job) {
429 return job.waitUntilFinished(this.queueEvents[job.queueName])
430 }
431
432 private addRepeatableJobs () { 443 private addRepeatableJobs () {
433 this.queues['videos-views-stats'].add('job', {}, { 444 this.queues['videos-views-stats'].add('job', {}, {
434 repeat: REPEAT_JOBS['videos-views-stats'] 445 repeat: REPEAT_JOBS['videos-views-stats']