feat: add lock method to LockRepository for managing room locks with …#238
feat: add lock method to LockRepository for managing room locks with …#238
Conversation
…disposal functionality
WalkthroughThe PR converts per-room processing to an async-generator pipeline, moving from Promise-based handlers to streaming iteration. It introduces a lock repository and integrates lock acquisition/updates in the queue processor. EventService now enqueues without acquiring locks. Listener and StagingAreaService adopt generator-based control flow. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Producer as EventSource
participant EventService
participant StagingAreaQueue as Queue
participant LockRepository as LockRepo
participant StagingAreaService as StagingSvc
Producer->>EventService: Incoming PDU(s) / startup scan
EventService->>Queue: enqueue(roomId)
Note over Queue: Processing loop (per room)
Queue->>LockRepo: lock(roomId, instanceId)
alt lock acquired
LockRepo-->>Queue: { success: true, update(), [asyncDispose]() }
Queue->>StagingSvc: processEventForRoom(roomId) [async generator]
loop For each yielded item
StagingSvc-->>Queue: yield nextStep/undefined
Queue->>LockRepo: update()
end
Queue->>LockRepo: [asyncDispose]() (release)
else lock not acquired
LockRepo-->>Queue: { success: false, ... }
Note over Queue: Skip processing this room
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (5)
💤 Files with no reviewable changes (1)
🧰 Additional context used🧬 Code graph analysis (2)packages/federation-sdk/src/queues/staging-area.queue.ts (3)
packages/federation-sdk/src/repositories/lock.repository.ts (2)
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #238 +/- ##
=======================================
Coverage 81.86% 81.86%
=======================================
Files 63 63
Lines 4709 4709
=======================================
Hits 3855 3855
Misses 854 854 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…disposal functionality
Summary by CodeRabbit
Refactor
Bug Fixes