[next] Concurrency (#2136)

* feat: added concurrency options

* fix: Default CONCURRENCY to 2 for development
This commit is contained in:
Wyatt Johnson
2018-12-20 17:01:10 +00:00
committed by GitHub
parent 1fc49f8e50
commit 326a10dc5d
9 changed files with 217 additions and 66 deletions
+6 -4
View File
@@ -18,9 +18,6 @@ export default class Task<T, U = any> {
this.queue = new Queue(options.jobName, options.queue);
this.options = options;
this.log = logger.child({ jobName: options.jobName });
// Sets up and attaches the job processor to the queue.
this.setupAndAttachProcessor();
}
/**
@@ -39,7 +36,12 @@ export default class Task<T, U = any> {
this.log.trace({ jobID: job.id }, "added job to queue");
return job;
}
private setupAndAttachProcessor() {
/**
* process will connect the queue to the processor so that it may process the
* job requests.
*/
public process() {
this.queue.process(async (job: Job<T>) => {
const log = this.log.child({ jobID: job.id });
@@ -193,6 +193,13 @@ export class Mailer {
},
});
}
/**
* process maps the interface to the task process function.
*/
public process() {
return this.task.process();
}
}
export const createMailerTask = (