spakky-mediator¶
명시적으로 설치·선택하는 로컬 domain event consumer·dispatcher입니다.
spakky-event의 계약·발행과 Kafka/RabbitMQ의 외부 소비를 독립적으로 조합합니다.
플러그인 진입점¶
Opt-in local domain event provider registration.
initialize(app)
¶
Register only in-process domain consumer and dispatcher implementations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app
|
SpakkyApplication
|
Application selecting the optional mediator provider. |
required |
Source code in plugins/spakky-mediator/src/spakky/plugins/mediator/main.py
Consumer와 Dispatcher¶
Event mediator implementations.
This module provides in-process mediator implementations that combine Consumer and Dispatcher interfaces. Mediators manage handler registration and event dispatching within the same bounded context.
EventMediator()
¶
Bases: IDomainEventConsumer, IEventDispatcher
In-process synchronous event mediator combining consumer and dispatcher roles.
Initialize an empty handler registry.
Source code in plugins/spakky-mediator/src/spakky/plugins/mediator/mediator.py
register(event, handler)
¶
Register a handler callback for the given event type.
Source code in plugins/spakky-mediator/src/spakky/plugins/mediator/mediator.py
dispatch(event)
¶
Dispatch an event to all registered handlers.
Source code in plugins/spakky-mediator/src/spakky/plugins/mediator/mediator.py
AsyncEventMediator()
¶
Bases: IAsyncDomainEventConsumer, IAsyncEventDispatcher
In-process asynchronous event mediator combining consumer and dispatcher roles.
Initialize an empty async handler registry.
Source code in plugins/spakky-mediator/src/spakky/plugins/mediator/mediator.py
register(event, handler)
¶
Register an async handler callback for the given event type.
Source code in plugins/spakky-mediator/src/spakky/plugins/mediator/mediator.py
dispatch(event)
async
¶
Dispatch an event to all registered async handlers.
Source code in plugins/spakky-mediator/src/spakky/plugins/mediator/mediator.py
Domain Handler 등록¶
Event handler registration post-processor.
EventHandlerRegistrationPostProcessor
¶
Bases: IPostProcessor, IContainerAware
Scans @EventHandler Pods and registers their @on_event methods with consumers.
set_container(container)
¶
Receive the container reference via IContainerAware.
post_process(pod)
¶
Register event handler methods with the appropriate consumer.
Source code in plugins/spakky-mediator/src/spakky/plugins/mediator/post_processor.py
이전¶
9.0.0의 설치·부트스트랩·consumer 역할 변경은 이벤트 9.0 마이그레이션을 참고하세요.
로컬 dispatch를 사용하는 앱은 spakky-mediator 또는 spakky[mediator]를 설치하고
Plugin(name="spakky-mediator")를 명시적으로 선택합니다. 구체 구현 import는
spakky.plugins.mediator.mediator와 spakky.plugins.mediator.post_processor로 옮깁니다.
spakky.event의 consumer·dispatcher 인터페이스와 handler stereotype은 유지됩니다.