import { JobProcessor } from '@dunx/infra/queue'; import { Module } from '@dunx/core'; import { OtelModule } from '@dunx/core/otel'; import { LoggerModule } from '@dunx/infra/logger'; import { AppConfigService, configModule } from '../config.js'; import { JobsModule } from './jobs.module.js'; /** * The file bullmq forks into; its default export is the processor. The child * builds its own container, so a handler gets what it declares without sharing * an event loop with the HTTP process. Its own module rather than `worker.ts`, * which has a `run()` that would boot a second worker inside every child. */ @Module({ imports: [ configModule(), LoggerModule.forRootAsync({ useFactory: (config: AppConfigService) => ({ // Named, so a line from a child is attributable on sight. name: `${config.get('appName')}-job`, level: config.get('log').level, }), inject: [AppConfigService] as const, }), // A job continues the publisher's trace once this process registers an SDK. OtelModule, JobsModule, ], }) class JobProcessorModule {} export default new JobProcessor(JobProcessorModule).handle;