feat(pipelines): 添加消息队列

This commit is contained in:
Ivan
2021-03-02 16:28:37 +08:00
parent 22d9bf47d3
commit 31a200206f
3 changed files with 38 additions and 6 deletions

View File

@ -44,13 +44,12 @@ export class PipelineTasksService {
}
}
async doTask(task: PipelineTask) {
const tasksKey = this.getRedisTokens(task.pipeline)[1];
async doNextTask(pipeline: Pipeline) {
const tasksKey = this.getRedisTokens(pipeline)[1];
const redis = this.redis.getClient();
const nextTask = await redis.rpop(tasksKey);
if (nextTask) {
this.doTask(task).then();
const task = JSON.parse((await redis.rpop(tasksKey)) ?? 'null');
if (task) {
this.queue.add(task);
}
}