Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add another polling: by job status #4

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/models/jobProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class JobProcessor {
const logCtx: LogContext = { ...this.logContext, function: this.start.name };
this.logger.info({ msg: 'starting polling', logContext: logCtx });
while (this.isRunning) {
await this.consumeAndProcess();
await Promise.all([this.jobByTaskTypePolling(), this.jobStatusPolling()]);
}
}

Expand All @@ -46,8 +46,16 @@ export class JobProcessor {
this.isRunning = false;
}

private async consumeAndProcess(): Promise<void> {
const logCtx: LogContext = { ...this.logContext, function: this.consumeAndProcess.name };
public async jobStatusPolling(): Promise<void> {
try {
await Promise.reject('not implemented');
} catch (error) {
this.logger.error({ msg: 'not implemented', error });
}
}

private async jobByTaskTypePolling(): Promise<void> {
const logCtx: LogContext = { ...this.logContext, function: this.jobByTaskTypePolling.name };
try {
const jobAndTaskType = await this.getJobWithTaskType();

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/jobProcessor/JobProcessor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('JobProcessor', () => {
});
});

describe('consumeAndProcess', () => {
describe('jobByTaskTypePolling', () => {
test.each(initTestCases)('should process job of type $jobType and init task successfully', async ({ job, task }) => {
testContext = setupJobProcessorTest({ useMockQueueClient: true });
const { jobProcessor, mockDequeue, mockGetJob, mockJobHandlerFactory, configMock } = testContext;
Expand Down
Loading