Create BullMQ module that shares the existing Valkey connection for job queue processing. Files Created: - apps/api/src/bullmq/bullmq.module.ts - Global module configuration - apps/api/src/bullmq/bullmq.service.ts - Queue management service - apps/api/src/bullmq/queues.ts - Queue name constants - apps/api/src/bullmq/index.ts - Barrel exports - apps/api/src/bullmq/bullmq.service.spec.ts - Unit tests Files Modified: - apps/api/src/app.module.ts - Import BullMqModule Queue Definitions: - mosaic-jobs (main queue) - mosaic-jobs-runner (read-only operations) - mosaic-jobs-weaver (write operations) - mosaic-jobs-inspector (validation operations) Implementation: - Reuses VALKEY_URL from environment (shared connection) - Follows existing Valkey module patterns - Includes health check methods - Proper lifecycle management (init/destroy) - Queue names use hyphens instead of colons (BullMQ requirement) Quality Gates: - Unit tests: 11 passing - TypeScript: No errors - ESLint: No violations - Build: Successful Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1.4 KiB
1.4 KiB
Issue #165: BullMQ Module Setup
Objective
Create BullMQ module that shares the existing Valkey connection for job queue processing.
Approach
- Examine existing Valkey configuration patterns
- Write tests for BullMQ module (TDD - RED)
- Implement BullMQ module components
- Integrate with app.module.ts
- Run quality gates
Progress
- Create scratchpad
- Examine existing Valkey configuration
- Write unit tests (RED phase)
- Create queue definitions
- Implement BullMQ service
- Implement BullMQ module
- Add to app.module.ts
- Run quality gates (typecheck, lint, build, test)
- Commit changes
Testing
- Unit tests for BullMQ service
- Queue creation verification
- Valkey connection validation
Notes
- Prerequisites: Issue #163 completed (dependencies installed)
- Must reuse VALKEY_URL from environment
- Queue naming convention changed from
mosaic:jobs:*tomosaic-jobs-*(BullMQ doesn't allow colons) - Unit tests pass without requiring Redis connection (tests validate configuration and structure)
- All quality gates passed: typecheck, lint, build, test
Implementation Details
- Created 4 queues: main, runner, weaver, inspector
- Follows existing Valkey module patterns
- Uses ioredis connection under the hood (BullMQ requirement)
- Includes health check methods for monitoring
- Proper cleanup in onModuleDestroy lifecycle hook