| name | microservice-patterns |
| description | Event-driven microservice architecture patterns guide. Use when the user requests implementing microservices, event bus, SAGA pattern, orchestration, compensating transactions, or distributed system coordination. |
Microservice Patterns Skill
์ด๋ฒคํธ ๋๋ฆฌ๋ธ ๋ง์ดํฌ๋ก์๋น์ค ์ํคํ
์ฒ ํจํด ๊ฐ์ด๋
์๋น์ค ์ํคํ
์ฒ
EventBus (pub/sub)
/ | \ \
OrderService InventoryService PaymentService NotificationService
| | | |
orders[] inventory{} payments[] notifications[]
\ | /
SAGA Orchestrator
(์ฃผ๋ฌธ ์์ฑ ํ๋ก์ฐ ์กฐ์จ)
ํต์ฌ ๊ท์น
- ์๋น์ค ๊ฐ ์ง์ ์ฐธ์กฐ ๊ธ์ง (์ด๋ฒคํธ๋ก๋ง ํต์ )
- ๊ฐ ์๋น์ค๋ ์์ฒด ์ํ๋ง ๊ด๋ฆฌ
- correlation ID๋ก ์ด๋ฒคํธ ํ๋ฆ ์ถ์
- ํ์์์: SAGA ๋จ๊ณ๋ณ 5์ด ์ ํ
SAGA ํ๋ก์ฐ
์ ์: order.created โ inventory.reserved โ payment.completed โ order.confirmed
์ฌ๊ณ ์คํจ: order.created โ inventory.failed โ order.cancelled
๊ฒฐ์ ์คํจ: order.created โ inventory.reserved โ payment.failed โ inventory.released โ order.cancelled
๋ณด์ ํธ๋์ญ์
์ ์คํ๋ ๋จ๊ณ์ ์ญ์์ผ๋ก ์ํ.
์ด๋ฒคํธ ๋ค์ด๋ฐ ๊ท์น
order.created, order.confirmed, order.cancelled
inventory.reserved, inventory.released, inventory.failed
payment.completed, payment.failed, payment.refunded
notification.sent
ํ์ผ ๊ตฌ์กฐ
src/
event-bus.js - ์ด๋ฒคํธ ๋ฒ์ค (pub/sub, ์์ผ๋์นด๋, ๋น๋๊ธฐ)
saga-orchestrator.js - SAGA ํจํด ์ค์ผ์คํธ๋ ์ดํฐ
services/
order-service.js - ์ฃผ๋ฌธ CRUD + ์ํ ๊ด๋ฆฌ
inventory-service.js - ์ฌ๊ณ ๊ด๋ฆฌ (reserve/release/deduct, ๋๊ด์ ์ ๊ธ)
payment-service.js - ๊ฒฐ์ ์ฒ๋ฆฌ (charge/refund, ๋ฉฑ๋ฑ์ฑ)
notification-service.js - ์๋ฆผ ์ด๋ ฅ
utils/
correlation-id.js - ์๊ด๊ด๊ณ ID ์์ฑ
logger.js - ์ด๋ฒคํธ ์ถ์ ๋ก๊ฑฐ
tests/
event-bus.test.js
saga.test.js
integration.test.js - 5๊ฐ ์๋๋ฆฌ์ค ํตํฉ ํ
์คํธ
ํ
์คํธ ์๋๋ฆฌ์ค (5๊ฐ ํ์)
- ์ ์ ํ๋ก์ฐ: ์ฃผ๋ฌธโ์ฌ๊ณ ์์ฝโ๊ฒฐ์ โํ์ , ๋ชจ๋ ์๋น์ค ์ํ ๊ฒ์ฆ
- ์ฌ๊ณ ๋ถ์กฑ: ์ฃผ๋ฌธโ์ฌ๊ณ ์คํจโ์ทจ์, ์ฃผ๋ฌธ ์ํ CANCELLED
- ๊ฒฐ์ ์คํจ: ์ฃผ๋ฌธโ์ฌ๊ณ ์์ฝโ๊ฒฐ์ ์คํจโ์ฌ๊ณ ํด์ โ์ทจ์, ์ฌ๊ณ ์๋ณต ํ์ธ
- ๋์ ์ฃผ๋ฌธ: 2๊ฐ ์ฃผ๋ฌธ์ด ๋์์ ๊ฐ์ ์ํ ์ฃผ๋ฌธ, ํ๋๋ง ์ฑ๊ณต
- ํ์์์: SAGA ๋จ๊ณ๊ฐ ์๊ฐ ์ด๊ณผ ์ ๋ณด์ ํธ๋์ญ์