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

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

by 오현석, 해리 퍼시벌, 밥 그레고리
June 2021
Beginner to intermediate
356 pages
8h 13m
Korean
Hanbit Media, Inc.
Content preview from 파이썬으로 살펴보는 아키텍처 패턴
183
8
이벤트와 메시지 버스
8.3.4
메시지 버스는 이벤트를 핸들러에 매핑한다
메시지 버스는 기본적으로 “이 이벤트가 발생하면 다음 핸들러 함수를 호출해야 한다”라고 말
한다. 다른 말로, 메시지 버스는 간단한 발행/구독 시스템
publish
-
subscribe
system
이다. 핸들러는 수
신된 이벤트를
구독
subscribed
한다. 수신되는 이벤트는 버스에 시스템이 발행한 것이다. 글로 쓰
면 실제보다 더 어려워 보이지만 보통은 사전을 활용해 메시지 버스를 구현한다.
간단한 메시지 버스(
src
/
allocation
/
service
_
layer
/
messagebus
.
py
)
def handle(event: events.Event):
for handler in HANDLERS[type(event)]:
handler(event)
def send_out_of_stock_notification(event: events.OutOfStock):
email.send_mail(
‘stock@made.com’,
f’Out of stock for {event.sku}’,
)
HANDLERS = {
events.OutOfStock: [send_out_of_stock_notification],
} # type: Dict[Type[events.Event], List[Callable]] ...
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