+ const jobOptions = this.buildJobOptions(options.type as JobType, pick(options, [ 'priority', 'delay' ]))
+
+ return queue.add('job', options.payload, jobOptions)
+ }
+
+ createSequentialJobFlow (...jobs: ((CreateJobArgument & CreateJobOptions) | undefined)[]) {
+ let lastJob: FlowJob
+
+ for (const job of jobs) {
+ if (!job) continue
+
+ lastJob = {
+ ...this.buildJobFlowOption(job),
+
+ children: lastJob
+ ? [ lastJob ]
+ : []
+ }
+ }
+
+ return this.flowProducer.add(lastJob)
+ }
+
+ createJobWithChildren (parent: CreateJobArgument & CreateJobOptions, children: (CreateJobArgument & CreateJobOptions)[]) {
+ return this.flowProducer.add({
+ ...this.buildJobFlowOption(parent),
+
+ children: children.map(c => this.buildJobFlowOption(c))
+ })
+ }
+
+ private buildJobFlowOption (job: CreateJobArgument & CreateJobOptions): FlowJob {
+ return {
+ name: 'job',
+ data: job.payload,
+ queueName: job.type,
+ opts: {
+ failParentOnFailure: true,
+
+ ...this.buildJobOptions(job.type as JobType, pick(job, [ 'priority', 'delay', 'failParentOnFailure' ]))
+ }
+ }
+ }
+
+ private buildJobOptions (type: JobType, options: CreateJobOptions = {}): JobsOptions {
+ return {