fix: removed event store consumer and lifecycle#133
Conversation
…es directly through event store
📝 WalkthroughWalkthroughConsolidates event-store consumer lifecycle into DI providers: removes Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
backend/app/core/dishka_lifespan.py (1)
79-107:⚠️ Potential issue | 🔴 CriticalAdd explicit container shutdown to prevent resource leaks.
The lifespan ends with a bare
yieldbut never closes the Dishka container. Per Dishka's FastAPI integration pattern,setup_dishka()manages request/session scopes automatically, but app-scoped resource cleanup is your responsibility. Add:yield await app.state.dishka_container.close()Without this, app-scoped providers (Kafka consumers, Redis, MongoDB connections, etc.) won't finalize on shutdown, causing resource leaks and potential hangs during graceful shutdown.
🧹 Nitpick comments (1)
backend/app/events/core/dispatcher.py (1)
10-54: Alignregistertyping with the newEventHandleralias.
EventHandlernow allowsAwaitable[Any], but the decorator still constrains handlers toAwaitable[None], which blocks handlers returning values from using the decorator and can trigger type-checker errors. Consider widening the decorator signature for consistency.♻️ Proposed typing alignment
def register( self, event_type: EventType -) -> Callable[[Callable[[T], Awaitable[None]]], Callable[[T], Awaitable[None]]]: +) -> Callable[[Callable[[T], Awaitable[Any]]], Callable[[T], Awaitable[Any]]]: @@ - def decorator(handler: Callable[[T], Awaitable[None]]) -> Callable[[T], Awaitable[None]]: + def decorator(handler: Callable[[T], Awaitable[Any]]) -> Callable[[T], Awaitable[Any]]: self.logger.info(f"Registering handler '{handler.__name__}' for event type '{event_type}'") # Safe: dispatch() routes by event_type, guaranteeing correct types at runtime self._handlers[event_type].append(self._wrap_handler(handler)) # type: ignore[arg-type] return handler
|



Summary by cubic
Removed the EventStoreConsumer and lifecycle management. The Kafka consumer now lives in the DI provider and dispatches events directly to EventStore, simplifying startup and reducing moving parts.
Written for commit d1dc667. Summary will update on new commits.
Summary by CodeRabbit
Refactor
Tests