import { Injectable } from '@nestjs/common' ; import { OCRMeta , MessageMeta , QueueProcessor , QueueMeta , QueueTypes , } from './meta.types' ; import { QueueService } from './queue.service' ; @ Injectable ( ) export class MemoryQueueService implements QueueService { private processors = new Map < QueueTypes , QueueProcessor < any > > ( ) ; public async process < T extends keyof { ocr : OCRMeta ; message : MessageMeta ; } > ( queue , handler , concurrency ) { this . processors . set ( queue , handler ) ; } public async add < T extends keyof { ocr : OCRMeta ; message : MessageMeta ; } > ( queue , data ) { const processor = this . processors . get ( queue ) ; if ( ! processor ) { throw new Error ( `Queue ${ queue } processor not found` ) ; } await processor ( data ) ; } }