Commit 93bd5594 authored by nanahira's avatar nanahira

add i to queue runner

parent 4bd1da3c
import { Aragami, ClassType } from 'aragami';
import { Logger } from '@nestjs/common';
import { ConsoleLogger, Logger } from '@nestjs/common';
import * as os from 'os';
import { InjectAragami } from '../index';
......@@ -29,7 +29,7 @@ export class _QueueRunner<T> {
if (this._queueRunnerOptions.logTask) {
this.logger.log(`Starting worker ${i}`);
}
this._mainLoop().then();
this._mainLoop(i).then();
}
}
......@@ -39,13 +39,14 @@ export class _QueueRunner<T> {
this._quit = true;
}
async runTask(task: T) {
async runTask(task: T, i: number) {
return;
}
async _mainLoop() {
async _mainLoop(i: number) {
const logger = new ConsoleLogger(`${this._queueClass.name}-${i}`);
while (!this._quit) {
this.logger.log('Looping');
logger.log('Looping');
try {
const task: T = await this.aragami.queueGatherBlocking(
this._queueClass,
......@@ -53,11 +54,11 @@ export class _QueueRunner<T> {
);
if (!task) continue;
if (this._queueRunnerOptions.logTask) {
this.logger.log(`Got task: ${JSON.stringify(task)}`);
logger.log(`Got task: ${JSON.stringify(task)}`);
}
await this.runTask(task);
await this.runTask(task, i);
} catch (e) {
this.logger.error(`Loop failed: ${e}`);
logger.error(`Loop failed: ${e}`);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment