Conversation
IP-7072 [compose] EventBus 타입 기반 의존성 해결로 전환
배경
목표
완료 조건
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (19)
Walkthrough의존성 주입 모듈 구조가 재구성되었습니다. 기존 문자열 기반의 컨테이너 경로 조회에서 타입 기반의 비동기 해석 방식으로 전환되었으며, 새로운 이벤트 핸들러 리졸버 팩토리가 도입되었습니다. EventBus API가 업데이트되어 Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant EventBus
participant Resolver
participant Container
Client->>EventBus: register(event_cls)<br/>decorator: `@register`(event_cls)
activate EventBus
EventBus->>EventBus: store handler_type in<br/>event→handler_types set
deactivate EventBus
Client->>EventBus: handle_event(event)
activate EventBus
EventBus->>EventBus: get handler_types for event
loop for each handler_type
EventBus->>Resolver: resolver(handler_type)
activate Resolver
Resolver->>Container: resolve by type
Container-->>Resolver: handler_instance
deactivate Resolver
EventBus->>EventBus: await handler_instance.handle(event)
end
deactivate EventBus
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
목적
EventBus의 핸들러 해결 방식을 이름 기반(str, sync)에서 타입 기반(type, async)으로 전환하여 DI 라이브러리 중립적으로 변경하고,
compose.di패키지를 라이브러리별 서브패키지로 재구성변경 사항
compose.di패키지 구조 재구성compose/di/{container,provider,wiring}.py를compose/di/dependency_injector/로 이동compose/di/dishka/서브패키지 신규 생성compose.di.__init__에서 기존 심볼 re-export 유지하여 하위호환 보장compose.dependency,compose.fastapi내부 import 경로 업데이트DI 라이브러리별 EventHandler resolver 팩토리 제공
compose.di.dependency_injector.wiring.create_event_handler_resolver추가compose.di.dishka.create_event_handler_resolver추가EventBus 타입 기반 async resolver 전환
dependency_resolver시그니처:Callable[[str], EventHandler]->Callable[[type[EventHandler]], Awaitable[EventHandler]]_event_handlers저장소:dict[str, set[str]]->dict[str, set[type[EventHandler]]]with_container클래스메서드 및create_lazy_resolver제거compose.diimport 제거 (DI 라이브러리 비의존)사용법
EventBus 생성 (dependency-injector)
EventBus 생성 (dishka)
핸들러 등록 (변경 없음)
Summary by CodeRabbit
릴리스 노트
새로운 기능
리팩토링
테스트