Skip to content

Commit

Permalink
feat: queue support concurrency config (#1231)
Browse files Browse the repository at this point in the history
* feat: queue support concurrency config

* refactor: remove redundant code
  • Loading branch information
EliYao committed Aug 16, 2021
1 parent 5de5284 commit 67bb7f5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/task/src/config/config.default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export const taskConfig = {
tz: 'Asia/Shanghai',
},
},
concurrency: 1,
};
3 changes: 2 additions & 1 deletion packages/task/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,12 @@ export class AutoConfiguration {
const modules = listModule(MODULE_TASK_QUEUE_KEY);
const queueMap = {};
const config = JSON.parse(JSON.stringify(this.taskConfig));
const concurrency = config.concurrency || 1;
delete config.defaultJobOptions.repeat;
for (const module of modules) {
const rule = getClassMetadata(MODULE_TASK_QUEUE_OPTIONS, module);
const queue = new Bull(`${rule.name}:execute`, config);
queue.process(async job => {
queue.process(concurrency, async job => {
const ctx = this.getContext({
type: 'Queue',
id: job.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export const taskConfig = {
tz: 'Asia/Shanghai',
},
},
concurrency: 1,
};

0 comments on commit 67bb7f5

Please sign in to comment.