Skip to Content
파이썬으로 살펴보는 아키텍처 패턴
book

파이썬으로 살펴보는 아키텍처 패턴

by 오현석, 해리 퍼시벌, 밥 그레고리
June 2021
Beginner to intermediate
356 pages
8h 13m
Korean
Hanbit Media, Inc.
Content preview from 파이썬으로 살펴보는 아키텍처 패턴
278
2
이벤트 기반 아키텍처
13.6
실행 도중 핸들러가 제공된 메시지 버스
이제 메시지 버스는 더 이상 정적인 존재가 아니다.
DI
가 끝난 핸들러가 메시지 버스로 전달되
어야 한다. 따라서 모듈에서 설정 가능한 클래스로 메시지 버스를 변경해야 한다.
클래스로 정의한 메시지 버스(
src
/
allocation
/
service
_
layer
/
messagebus
.
py
)
class MessageBus: # ①
def __init__(
self,
uow: unit_of_work.AbstractUnitOfWork,
event_handlers: Dict[Type[events.Event], List[Callable]], # ②
command_handlers: Dict[Type[commands.Command], Callable], # ②
):
self.uow = uow
self.event_handlers = event_handlers
self.command_handlers = command_handlers
def handle(self, message: Message): # ③
self.queue = [message] # ④
while self.queue:
message = self.queue.pop(0)
if isinstance(message, events.Event): ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

효율적인 리눅스 명령어 사용의 기술

효율적인 리눅스 명령어 사용의 기술

Daniel J Barrett
쿠버네티스를 활용한 클라우드 네이티브 데브옵스

쿠버네티스를 활용한 클라우드 네이티브 데브옵스

최경현, 저스틴 도밍거스, 존 어런들

Publisher Resources

ISBN: 9791162244319