From 693a0431c49b97d2291921f055ab5e639192cd92 Mon Sep 17 00:00:00 2001 From: almog8k Date: Mon, 29 Jul 2024 19:34:08 +0300 Subject: [PATCH] fix: pr issues --- src/common/interfaces.ts | 6 +++++- src/models/jobProcessor.ts | 7 +++---- src/models/newJobHandler.ts | 4 ++-- src/models/swapJobHandler.ts | 4 ++-- src/models/updateJobHandler.ts | 4 ++-- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/common/interfaces.ts b/src/common/interfaces.ts index e05660f..6aefe13 100644 --- a/src/common/interfaces.ts +++ b/src/common/interfaces.ts @@ -1,4 +1,3 @@ -import { NewRasterLayer, UpdateRasterLayer } from '@map-colonies/mc-model-types'; import { IJobResponse } from '@map-colonies/mc-priority-queue'; //#region config interfaces @@ -55,3 +54,8 @@ export interface IJobHandler { // eslint-disable-next-line @typescript-eslint/no-explicit-any handleJobFinalize: (job: IJobResponse) => Promise; } + +export interface JobAndTaskType { + job: IJobResponse; + taskType: string; +} diff --git a/src/models/jobProcessor.ts b/src/models/jobProcessor.ts index 933214f..ab2d086 100644 --- a/src/models/jobProcessor.ts +++ b/src/models/jobProcessor.ts @@ -2,10 +2,9 @@ import { setTimeout as setTimeoutPromise } from 'timers/promises'; import { Logger } from '@map-colonies/js-logger'; import { inject, injectable } from 'tsyringe'; import { TaskHandler as QueueClient } from '@map-colonies/mc-priority-queue'; -import { IJobResponse } from '@map-colonies/mc-priority-queue'; import { getAvailableJobTypes } from '../utils/configUtil'; import { SERVICES } from '../common/constants'; -import { IConfig, IngestionConfig, LogContext } from '../common/interfaces'; +import { IConfig, IngestionConfig, JobAndTaskType, LogContext } from '../common/interfaces'; import { JOB_HANDLER_FACTORY_SYMBOL, JobHandlerFactory } from './jobHandlerFactory'; @injectable() @@ -64,7 +63,7 @@ export class JobProcessor { } } - private async processJob(jobAndTaskType: { job: IJobResponse; taskType: string }): Promise { + private async processJob(jobAndTaskType: JobAndTaskType): Promise { const { job, taskType } = jobAndTaskType; const taskTypes = this.ingestionConfig.pollingTasks; const jobHandler = this.jobHandlerFactory(job.type); @@ -79,7 +78,7 @@ export class JobProcessor { } } - private async getJobWithTaskType(): Promise<{ job: IJobResponse; taskType: string } | undefined> { + private async getJobWithTaskType(): Promise { const logCtx: LogContext = { ...this.logContext, function: this.getJobWithTaskType.name }; for (const taskType of this.pollingTaskTypes) { for (const jobType of this.jobTypes) { diff --git a/src/models/newJobHandler.ts b/src/models/newJobHandler.ts index a157c76..1998a69 100644 --- a/src/models/newJobHandler.ts +++ b/src/models/newJobHandler.ts @@ -17,13 +17,13 @@ export class NewJobHandler implements IJobHandler { public async handleJobInit(job: IJobResponse): Promise { const logCtx: LogContext = { ...this.logContext, function: this.handleJobInit.name }; - this.logger.info({ msg: 'handling "new" job "init"', metadata: { job }, logContext: logCtx }); + this.logger.info({ msg: `handling ${job.type} job with "init" task`, metadata: { job }, logContext: logCtx }); await Promise.reject('not implemented'); } public async handleJobFinalize(job: IJobResponse): Promise { const logCtx: LogContext = { ...this.logContext, function: this.handleJobFinalize.name }; - this.logger.info({ msg: 'handling "new" job "finalize"', metadata: { job }, logContext: logCtx }); + this.logger.info({ msg: `handling ${job.type} job with "finalize"`, metadata: { job }, logContext: logCtx }); await Promise.reject('not implemented'); } } diff --git a/src/models/swapJobHandler.ts b/src/models/swapJobHandler.ts index 0071390..f068ec9 100644 --- a/src/models/swapJobHandler.ts +++ b/src/models/swapJobHandler.ts @@ -14,13 +14,13 @@ export class SwapJobHandler implements IJobHandler { public async handleJobInit(job: IJobResponse): Promise { const logCtx: LogContext = { ...this.logContext, function: this.handleJobInit.name }; - this.logger.info({ msg: 'handling "swap update" job "init"', metadata: { job }, logContext: logCtx }); + this.logger.info({ msg: `handling ${job.type} job with "init" task`, metadata: { job }, logContext: logCtx }); await Promise.reject('not implemented'); } public async handleJobFinalize(job: IJobResponse): Promise { const logCtx: LogContext = { ...this.logContext, function: this.handleJobFinalize.name }; - this.logger.info({ msg: 'handling "swap update" job "finalize"', metadata: { job }, logContext: logCtx }); + this.logger.info({ msg: `handling ${job.type} job with "finalize" task`, metadata: { job }, logContext: logCtx }); await Promise.reject('not implemented'); } } diff --git a/src/models/updateJobHandler.ts b/src/models/updateJobHandler.ts index a10a19e..296352e 100644 --- a/src/models/updateJobHandler.ts +++ b/src/models/updateJobHandler.ts @@ -14,13 +14,13 @@ export class UpdateJobHandler implements IJobHandler { public async handleJobInit(job: IJobResponse): Promise { const logCtx: LogContext = { ...this.logContext, function: this.handleJobInit.name }; - this.logger.info({ msg: 'handling "update" job "init"', metadata: { job }, logContext: logCtx }); + this.logger.info({ msg: `handling ${job.type} job with "init" task`, metadata: { job }, logContext: logCtx }); await Promise.reject('not implemented'); } public async handleJobFinalize(job: IJobResponse): Promise { const logCtx: LogContext = { ...this.logContext, function: this.handleJobFinalize.name }; - this.logger.info({ msg: 'handling "update" job "finalize"', metadata: { job }, logContext: logCtx }); + this.logger.info({ msg: `handling ${job.type} job with "finalize" task`, metadata: { job }, logContext: logCtx }); await Promise.reject('not implemented'); } }