feat(artist): search service for artists#53
Conversation
Replace fire-and-forget search index synchronization with a transactional outbox pattern to guarantee eventual consistency between the database and search index. Previously, ArtistService and SongService called search.sync() directly after write operations. If the search service was unavailable, the sync would fail silently and the index would become stale. With this change: - Write operations now create outbox entries inside Prisma transactions - A BullMQ worker processes outbox jobs asynchronously to sync the index - Redis is added as the BullMQ backing store - Graceful shutdown handlers ensure in-flight jobs complete on exit New modules: - packages/core/src/modules/outbox/ (repository, service, DTOs) - packages/core/src/outbox/ (BullMQ queue and processor) - packages/db/prisma/models/meta/outbox.prisma (schema)
- Add BaseRepository with `query()` helper that wraps traceTask + transformPrismaResult, removing callback nesting from all repository methods - Migrate ArtistRepository, SongRepository, and EngineRepository to extend BaseRepository; method bodies are now fully flat - Remove traceTask from ArtistService and SongService, leaving only `$transaction` as the single nesting layer - Split OutboxService.createEntry into write-only (tx-bound) and enqueue (post-tx queue dispatch) to guarantee data consistency - Fix SongService unit test mock to include the new enqueue method
Add unit and integration tests for artist and engine modules. Add search index cleanup script for test isolation. Refactor catalog module imports to avoid barrel dependency issues.
Refactor outbox processor into a DI-based factory and inject queue into OutboxService to enable unit testing. Cover outbox service, processor, repository, artist search, and search manager with unit/integration tests.
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 54 minutes and 59 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (60)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Artist Search Service Implementation
artistSearchHandlerendpoint (GET /artists) with query parameter validation and full-text search capabilitiesArtistSearchServicewithsyncandsearchmethods for indexing and querying artist data across multiple languagesOutbox-Based Event Processing Architecture
OutboxPrisma model with status tracking (PENDING,PROCESSING,PROCESSED,FAILED) and retry managementOutboxRepositoryandOutboxServicefor creating, querying, and managing outbox entriesOutboxProcessorthat dispatches events to appropriate search services (song and artist) for index synchronizationArtistServiceandSongServiceto use outbox events instead of direct search index updatesTest Infrastructure Refactoring
beforeAll/afterAllhooks) from integration test filestest:resetscripts for database state reset prior to test executionConfiguration and Dependencies
redisservice to Docker Compose setup with persistent volumeREDIS_URLwith default local Redis connectionbullmqandioredisruntime dependencies to core packagetest:resettasks for database and core packagesSearch Index Enhancements
cleanUpSearchIndex.tsscript for search index rebuild across multiple languagesSearchManagerwithclearAllIndexandcreateIndexmethods for index administrationSongSearchIndexto support nullable embedding vectors for resilience to embedding failures