Skip to content

Commit

Permalink
fix: pr issues
Browse files Browse the repository at this point in the history
  • Loading branch information
almog8k committed Jul 29, 2024
1 parent b09b28b commit 693a043
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
6 changes: 5 additions & 1 deletion src/common/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { NewRasterLayer, UpdateRasterLayer } from '@map-colonies/mc-model-types';
import { IJobResponse } from '@map-colonies/mc-priority-queue';

//#region config interfaces
Expand Down Expand Up @@ -55,3 +54,8 @@ export interface IJobHandler {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
handleJobFinalize: (job: IJobResponse<any, any>) => Promise<void>;
}

export interface JobAndTaskType {
job: IJobResponse<unknown, unknown>;
taskType: string;
}
7 changes: 3 additions & 4 deletions src/models/jobProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -64,7 +63,7 @@ export class JobProcessor {
}
}

private async processJob(jobAndTaskType: { job: IJobResponse<unknown, unknown>; taskType: string }): Promise<void> {
private async processJob(jobAndTaskType: JobAndTaskType): Promise<void> {
const { job, taskType } = jobAndTaskType;
const taskTypes = this.ingestionConfig.pollingTasks;
const jobHandler = this.jobHandlerFactory(job.type);
Expand All @@ -79,7 +78,7 @@ export class JobProcessor {
}
}

private async getJobWithTaskType(): Promise<{ job: IJobResponse<unknown, unknown>; taskType: string } | undefined> {
private async getJobWithTaskType(): Promise<JobAndTaskType | undefined> {
const logCtx: LogContext = { ...this.logContext, function: this.getJobWithTaskType.name };
for (const taskType of this.pollingTaskTypes) {
for (const jobType of this.jobTypes) {
Expand Down
4 changes: 2 additions & 2 deletions src/models/newJobHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ export class NewJobHandler implements IJobHandler {

public async handleJobInit(job: IJobResponse<NewRasterLayer, unknown>): Promise<void> {
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<NewRasterLayer, unknown>): Promise<void> {
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');
}
}
4 changes: 2 additions & 2 deletions src/models/swapJobHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ export class SwapJobHandler implements IJobHandler {

public async handleJobInit(job: IJobResponse<UpdateRasterLayer, unknown>): Promise<void> {
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<UpdateRasterLayer, unknown>): Promise<void> {
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');
}
}
4 changes: 2 additions & 2 deletions src/models/updateJobHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ export class UpdateJobHandler implements IJobHandler {

public async handleJobInit(job: IJobResponse<UpdateRasterLayer, unknown>): Promise<void> {
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<UpdateRasterLayer, unknown>): Promise<void> {
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');
}
}

0 comments on commit 693a043

Please sign in to comment.