Browse Source

fix: job queue constant

Signed-off-by: mertmit <mertmit99@gmail.com>
feat/export-nest
mertmit 2 years ago
parent
commit
0b53f669d7
  1. 2
      packages/nocodb-nest/src/interface/Jobs.ts
  2. 4
      packages/nocodb-nest/src/modules/jobs/at-import/at-import.controller.ts
  3. 4
      packages/nocodb-nest/src/modules/jobs/at-import/at-import.processor.ts
  4. 4
      packages/nocodb-nest/src/modules/jobs/export-import/duplicate.controller.ts
  5. 4
      packages/nocodb-nest/src/modules/jobs/export-import/duplicate.processor.ts
  6. 3
      packages/nocodb-nest/src/modules/jobs/jobs-event.service.ts
  7. 3
      packages/nocodb-nest/src/modules/jobs/jobs.module.ts
  8. 3
      packages/nocodb-nest/src/modules/jobs/jobs.service.ts

2
packages/nocodb-nest/src/interface/Jobs.ts

@ -1,3 +1,5 @@
export const JOBS_QUEUE = 'jobs';
export enum JobTypes { export enum JobTypes {
DuplicateBase = 'duplicate-base', DuplicateBase = 'duplicate-base',
DuplicateModel = 'duplicate-model', DuplicateModel = 'duplicate-model',

4
packages/nocodb-nest/src/modules/jobs/at-import/at-import.controller.ts

@ -7,14 +7,14 @@ import { SyncSource } from '../../../models';
import { NcError } from '../../../helpers/catchError'; import { NcError } from '../../../helpers/catchError';
import { QueueService } from '../fallback-queue.service'; import { QueueService } from '../fallback-queue.service';
import { JobsService } from '../jobs.service'; import { JobsService } from '../jobs.service';
import { JobTypes } from '../../../interface/Jobs'; import { JOBS_QUEUE, JobTypes } from '../../../interface/Jobs';
@Controller() @Controller()
@UseGuards(ExtractProjectIdMiddleware, GlobalGuard) @UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
export class AtImportController { export class AtImportController {
activeQueue; activeQueue;
constructor( constructor(
@InjectQueue('jobs') private readonly jobsQueue: Queue, @InjectQueue(JOBS_QUEUE) private readonly jobsQueue: Queue,
private readonly fallbackQueueService: QueueService, private readonly fallbackQueueService: QueueService,
private readonly jobsService: JobsService, private readonly jobsService: JobsService,
) { ) {

4
packages/nocodb-nest/src/modules/jobs/at-import/at-import.processor.ts

@ -25,7 +25,7 @@ import { ViewColumnsService } from '../../../services/view-columns.service';
import { ViewsService } from '../../../services/views.service'; import { ViewsService } from '../../../services/views.service';
import { FormsService } from '../../../services/forms.service'; import { FormsService } from '../../../services/forms.service';
import { JobsEventService } from '../jobs-event.service'; import { JobsEventService } from '../jobs-event.service';
import { JobTypes } from '../../../interface/Jobs'; import { JOBS_QUEUE, JobTypes } from '../../../interface/Jobs';
import FetchAT from './helpers/fetchAT'; import FetchAT from './helpers/fetchAT';
import { importData, importLTARData } from './helpers/readAndProcessData'; import { importData, importLTARData } from './helpers/readAndProcessData';
import EntityMap from './helpers/EntityMap'; import EntityMap from './helpers/EntityMap';
@ -82,7 +82,7 @@ const selectColors = {
grayDarker: '#444', grayDarker: '#444',
}; };
@Processor('jobs') @Processor(JOBS_QUEUE)
export class AtImportProcessor { export class AtImportProcessor {
constructor( constructor(
private readonly tablesService: TablesService, private readonly tablesService: TablesService,

4
packages/nocodb-nest/src/modules/jobs/export-import/duplicate.controller.ts

@ -18,14 +18,14 @@ import { ProjectsService } from '../../../services/projects.service';
import { Base, Project } from '../../../models'; import { Base, Project } from '../../../models';
import { generateUniqueName } from '../../../helpers/exportImportHelpers'; import { generateUniqueName } from '../../../helpers/exportImportHelpers';
import { QueueService } from '../fallback-queue.service'; import { QueueService } from '../fallback-queue.service';
import { JobTypes } from '../../../interface/Jobs'; import { JOBS_QUEUE, JobTypes } from '../../../interface/Jobs';
@Controller() @Controller()
@UseGuards(ExtractProjectIdMiddleware, GlobalGuard) @UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
export class DuplicateController { export class DuplicateController {
activeQueue; activeQueue;
constructor( constructor(
@InjectQueue('jobs') private readonly jobsQueue: Queue, @InjectQueue(JOBS_QUEUE) private readonly jobsQueue: Queue,
private readonly fallbackQueueService: QueueService, private readonly fallbackQueueService: QueueService,
private readonly projectsService: ProjectsService, private readonly projectsService: ProjectsService,
) { ) {

4
packages/nocodb-nest/src/modules/jobs/export-import/duplicate.processor.ts

@ -6,14 +6,14 @@ import { Base, Column, Model, Project } from '../../../models';
import { ProjectsService } from '../../../services/projects.service'; import { ProjectsService } from '../../../services/projects.service';
import { findWithIdentifier } from '../../../helpers/exportImportHelpers'; import { findWithIdentifier } from '../../../helpers/exportImportHelpers';
import { BulkDataAliasService } from '../../../services/bulk-data-alias.service'; import { BulkDataAliasService } from '../../../services/bulk-data-alias.service';
import { JobTypes } from '../../../interface/Jobs'; import { JOBS_QUEUE, JobTypes } from '../../../interface/Jobs';
import { ExportService } from './export.service'; import { ExportService } from './export.service';
import { ImportService } from './import.service'; import { ImportService } from './import.service';
import type { LinkToAnotherRecordColumn } from '../../../models'; import type { LinkToAnotherRecordColumn } from '../../../models';
const DEBUG = false; const DEBUG = false;
@Processor('jobs') @Processor(JOBS_QUEUE)
export class DuplicateProcessor { export class DuplicateProcessor {
constructor( constructor(
private readonly exportService: ExportService, private readonly exportService: ExportService,

3
packages/nocodb-nest/src/modules/jobs/jobs-event.service.ts

@ -7,8 +7,9 @@ import {
import { Job } from 'bull'; import { Job } from 'bull';
import boxen from 'boxen'; import boxen from 'boxen';
import { EventEmitter2 } from '@nestjs/event-emitter'; import { EventEmitter2 } from '@nestjs/event-emitter';
import { JOBS_QUEUE } from '../../interface/Jobs';
@Processor('jobs') @Processor(JOBS_QUEUE)
export class JobsEventService { export class JobsEventService {
constructor(private eventEmitter: EventEmitter2) {} constructor(private eventEmitter: EventEmitter2) {}

3
packages/nocodb-nest/src/modules/jobs/jobs.module.ts

@ -3,6 +3,7 @@ import { BullModule } from '@nestjs/bull';
import { GlobalModule } from '../global/global.module'; import { GlobalModule } from '../global/global.module';
import { DatasModule } from '../datas/datas.module'; import { DatasModule } from '../datas/datas.module';
import { MetasModule } from '../metas/metas.module'; import { MetasModule } from '../metas/metas.module';
import { JOBS_QUEUE } from '../../interface/Jobs';
import { JobsService } from './jobs.service'; import { JobsService } from './jobs.service';
import { ExportService } from './export-import/export.service'; import { ExportService } from './export-import/export.service';
import { ImportService } from './export-import/import.service'; import { ImportService } from './export-import/import.service';
@ -20,7 +21,7 @@ import { AtImportProcessor } from './at-import/at-import.processor';
DatasModule, DatasModule,
MetasModule, MetasModule,
BullModule.registerQueue({ BullModule.registerQueue({
name: 'jobs', name: JOBS_QUEUE,
}), }),
], ],
controllers: [DuplicateController, AtImportController], controllers: [DuplicateController, AtImportController],

3
packages/nocodb-nest/src/modules/jobs/jobs.service.ts

@ -1,13 +1,14 @@
import { InjectQueue } from '@nestjs/bull'; import { InjectQueue } from '@nestjs/bull';
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { Queue } from 'bull'; import { Queue } from 'bull';
import { JOBS_QUEUE } from '../../interface/Jobs';
import { QueueService } from './fallback-queue.service'; import { QueueService } from './fallback-queue.service';
@Injectable() @Injectable()
export class JobsService { export class JobsService {
activeQueue; activeQueue;
constructor( constructor(
@InjectQueue('jobs') private readonly jobsQueue: Queue, @InjectQueue(JOBS_QUEUE) private readonly jobsQueue: Queue,
private readonly fallbackQueueService: QueueService, private readonly fallbackQueueService: QueueService,
) { ) {
this.activeQueue = process.env.NC_REDIS_URL this.activeQueue = process.env.NC_REDIS_URL

Loading…
Cancel
Save