Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: queue support concurrency config #1231

Merged
merged 2 commits into from
Aug 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
};