test / src /services /implementations /progress.service.ts
bipulsardar's picture
23
1d7d958
Raw History Blame Contribute Delete
901 Bytes
import { IProgressService } from '../interfaces/IProgressService';
import { ITaskQueueService } from '../interfaces/ITaskQueueService';
import { IWorkerService } from '../interfaces/IWorkerService';
export class ProgressService implements IProgressService {
private taskQueueService: ITaskQueueService;
private workerService: IWorkerService;
constructor(taskQueueService: ITaskQueueService, workerService: IWorkerService) {
this.taskQueueService = taskQueueService;
this.workerService = workerService;
}
public async recordProgress(
workerId: string,
taskId: string,
progress: number,
rowsProcessed?: number,
currentSpeed?: number
): Promise<void> {
await Promise.all([
this.taskQueueService.updateTaskProgress(taskId, progress, rowsProcessed),
this.workerService.recordHeartbeat(workerId, taskId, rowsProcessed, currentSpeed),
]);
}
}