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>
48 lines
1.4 KiB
Markdown
48 lines
1.4 KiB
Markdown
# Issue #165: BullMQ Module Setup
|
|
|
|
## Objective
|
|
|
|
Create BullMQ module that shares the existing Valkey connection for job queue processing.
|
|
|
|
## Approach
|
|
|
|
1. Examine existing Valkey configuration patterns
|
|
2. Write tests for BullMQ module (TDD - RED)
|
|
3. Implement BullMQ module components
|
|
4. Integrate with app.module.ts
|
|
5. Run quality gates
|
|
|
|
## Progress
|
|
|
|
- [x] Create scratchpad
|
|
- [x] Examine existing Valkey configuration
|
|
- [x] Write unit tests (RED phase)
|
|
- [x] Create queue definitions
|
|
- [x] Implement BullMQ service
|
|
- [x] Implement BullMQ module
|
|
- [x] Add to app.module.ts
|
|
- [x] Run quality gates (typecheck, lint, build, test)
|
|
- [x] 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:*` to `mosaic-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
|