mirror of https://github.com/nocodb/nocodb
Browse Source
* feat: move webhook handler to worker Signed-off-by: mertmit <mertmit99@gmail.com> * fix: move job data type to interfaces Signed-off-by: mertmit <mertmit99@gmail.com> --------- Signed-off-by: mertmit <mertmit99@gmail.com>pull/8536/head
Mert E
6 months ago
committed by
GitHub
15 changed files with 129 additions and 32 deletions
@ -0,0 +1,13 @@ |
|||||||
|
import type Bull from 'bull'; |
||||||
|
import type { JobStatus } from '~/interface/Jobs'; |
||||||
|
|
||||||
|
export interface IJobsService { |
||||||
|
jobsQueue: Bull.Queue; |
||||||
|
toggleQueue(): Promise<void>; |
||||||
|
add(name: string, data: any): Promise<Bull.Job<any>>; |
||||||
|
jobStatus(jobId: string): Promise<JobStatus>; |
||||||
|
jobList(): Promise<Bull.Job<any>[]>; |
||||||
|
getJobWithData(data: any): Promise<Bull.Job<any>>; |
||||||
|
resumeQueue(): Promise<void>; |
||||||
|
pauseQueue(): Promise<void>; |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
import { Process, Processor } from '@nestjs/bull'; |
||||||
|
import { forwardRef, Inject, Logger } from '@nestjs/common'; |
||||||
|
import { Job } from 'bull'; |
||||||
|
import { |
||||||
|
type HandleWebhookJobData, |
||||||
|
JOBS_QUEUE, |
||||||
|
JobTypes, |
||||||
|
} from '~/interface/Jobs'; |
||||||
|
import { HookHandlerService } from '~/services/hook-handler.service'; |
||||||
|
|
||||||
|
@Processor(JOBS_QUEUE) |
||||||
|
export class WebhookHandlerProcessor { |
||||||
|
private logger = new Logger(WebhookHandlerProcessor.name); |
||||||
|
|
||||||
|
constructor( |
||||||
|
@Inject(forwardRef(() => HookHandlerService)) |
||||||
|
private readonly hookHandlerService: HookHandlerService, |
||||||
|
) {} |
||||||
|
|
||||||
|
@Process(JobTypes.HandleWebhook) |
||||||
|
async job(job: Job<HandleWebhookJobData>) { |
||||||
|
await this.hookHandlerService.handleHooks(job.data); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue