import { AsyncQueue, createAsyncQueue } from 'common/AsyncQueue' import { singleton } from 'decorators/singleton' import { BlockChain } from 'chain/BlockChain' import logger from 'logger/logger' import { TaskSvr } from 'service/task.service' @singleton export class TaskQueue { private queue: AsyncQueue private blockChain: BlockChain constructor() { this.queue = createAsyncQueue() this.blockChain = new BlockChain() } public async addTaskToQueue(spNo: string) { this.queue.push(async () => { try { await new TaskSvr().parseOneTask(spNo) } catch (err) { logger.error('error add task: ' + err) } }) } }