Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 39s
M-AI-01-01: ADR-001 统一 AI 架构决策记录 + 附录 A 依赖闭包审计 M-AI-01-02: Worker 执行依赖闭包审计(附录 A 文档) M-AI-01-03: 分离 AppModule/WorkerModule Processor 注册 M-AI-01-04: 统一 Queue Definition Registry + 环境变量覆盖 M-AI-01-05: 独立 Worker 启动与生命周期(instanceId/校验/优雅关闭) M-AI-01-06: Docker + systemd 部署拓扑(unit 文件 + 回滚文档) M-AI-01-07: Worker Heartbeat(Redis TTL 90s)+ Admin 在线状态 API M-AI-01-08: 集成验收脚本 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
24 lines
933 B
TypeScript
24 lines
933 B
TypeScript
import { Processor, WorkerHost } from '@nestjs/bullmq';
|
|
import { Logger } from '@nestjs/common';
|
|
import { Job } from 'bullmq';
|
|
import { QUEUE_NOTIFICATION } from '../infrastructure/queue/queue.service';
|
|
import { workerOptionsFor } from '../infrastructure/queue/queue-definitions';
|
|
import { NotificationsService } from '../modules/notifications/notifications.service';
|
|
|
|
@Processor(QUEUE_NOTIFICATION, workerOptionsFor(QUEUE_NOTIFICATION))
|
|
export class NotificationWorker extends WorkerHost {
|
|
private readonly logger = new Logger(NotificationWorker.name);
|
|
|
|
constructor(
|
|
private readonly notificationsService: NotificationsService,
|
|
) {
|
|
super();
|
|
}
|
|
|
|
async process(job: Job<{ userId: string; type: string; title: string; body: string }>) {
|
|
this.logger.log(`Processing notification job ${job.id}`);
|
|
await this.notificationsService.send(job.data);
|
|
this.logger.log(`Notification job ${job.id} completed`);
|
|
}
|
|
}
|