patterns
Fungsinya
Dokumen ini adalah referensi untuk design pattern (pola desain) yang dipakai dalam pemrograman, seperti CQRS, Event Sourcing, dan Saga. Dokumen ini menjelaskan apa itu, kapan digunakan, dan bagaimana cara kerjanya.
Kapan dipakai
- βSaat Anda ingin mempelajari design pattern.
- βUntuk memahami cara mengatur sistem yang kompleks.
- βSaat mencari solusi untuk masalah umum dalam pengembangan software.
Link skill
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/monopoly/patterns/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βJelaskan kepada saya tentang Circuit Breaker pattern.β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Dokumen ini mencantumkan dan menjelaskan berbagai design pattern software. Untuk setiap pattern, dokumen ini merinci apa itu, kapan berguna, cara mengimplementasikannya, serta kelebihan dan kekurangannya.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
MONOPOLY β Design Patterns Deep Dive
When to Use
- Use this skill when the task matches this description: Reference document for monopoly patterns.
Table of Contents
- CQRS
- Event Sourcing
- Saga Pattern
- Circuit Breaker
- Bulkhead
- Strangler Fig
- Sidecar / Service Mesh
- Outbox Pattern
- Consistent Hashing
- Backpressure
- Leader Election
- Two-Phase Commit
1. CQRS (Command Query Responsibility Segregation)
What it is: Separate the read model (Query) from the write model (Command) into distinct services, databases, or code paths.
When to use:
- Read load is 10Γ+ write load (most web apps)
- Read queries are complex aggregations over write data
- Need to optimize read and write paths independently
- Domain model is complex (DDD contexts)
Implementation:
Write Path: Client β Command API β Write DB (normalized, PostgreSQL)
Read Path: Client β Query API β Read DB (denormalized, Redis / Elasticsearch)
Sync: Write DB β CDC (Debezium) β Message Queue β Read DB updater
Trade-offs:
- β Independent scaling of read and write
- β Optimized schemas for each operation type
- β Eventual consistency between write and read models
- β Increased complexity; two models to maintain
Real-world users: Amazon (order service), LinkedIn (feed)
2. Event Sourcing
What it is: Store state as a sequence of immutable events rather than current state. Rebuild current state by replaying events.
When to use:
- Full audit trail is a regulatory requirement (fintech, healthcare)
- Need to replay history for debugging or analytics
- Complex domain with many state transitions
- Need to derive multiple read projections from same data
Implementation:
Event Store: append-only log (Kafka, EventStoreDB)
Snapshots: periodic snapshots to speed up state rebuild
Projections: consumers build read models from events
Trade-offs:
- β Complete audit history; perfect for compliance
- β Replay and time-travel debugging
- β Querying current state requires projection maintenance
- β Event schema evolution is hard
- β High storage overhead over time
3. Saga Pattern
What it is: Manage distributed transactions across microservices via a sequence of local transactions, each publishing an event. If a step fails, compensating transactions undo previous steps.
Two variants:
- Choreography: Services react to events autonomously (decentralized)
- Orchestration: A central Saga Orchestrator coordinates steps (centralized)
When to use:
- Multi-service workflows where ACID across services is impossible
- Long-running business transactions (order β payment β inventory β shipping)
- Need rollback across service boundaries
Choreography Example:
OrderService creates order β
[event: OrderCreated] β
PaymentService charges card β
[event: PaymentProcessed] β
InventoryService reserves stock β
[event: StockReserved] β
ShippingService books courier
Compensating Transactions (on failure):
ShippingService fails β
[event: ShippingFailed] β
InventoryService releases stock β
PaymentService refunds card β
OrderService marks order failed
Trade-offs:
- β No distributed locking; high availability
- β Scales well across services
- β Hard to debug; distributed trace required
- β Compensating transactions are complex to implement correctly
4. Circuit Breaker
What it is: A proxy that monitors calls to a service. If failure rate exceeds threshold, the circuit "opens" and calls fail fast instead of waiting for timeout.
States:
CLOSED β calls pass through; monitor failure rate
OPEN β calls fail immediately; no calls to downstream
HALF-OPEN β let a probe call through; if success, close; if fail, stay open
When to use:
- Calling any external service (payment gateway, SMS, email)
- Microservices calling each other
- Preventing timeout cascade when downstream is slow
Implementation tools: Hystrix (deprecated), Resilience4j, Polly (.NET), Envoy proxy
Thresholds (starting point):
- Open after 50% failure rate over 10 requests
- Stay open for 30 seconds
- Half-open: allow 1 probe request
Trade-offs:
- β Prevents cascade failures
- β Gives downstream time to recover
- β Adds latency overhead for monitoring
- β Requires fallback behavior when circuit is open
5. Bulkhead
β¦
Pertanyaan umum
Apa itu 'design pattern'?
Itu adalah solusi yang bisa digunakan kembali untuk masalah umum dalam pengembangan software. Solusi ini membantu membuat kode yang lebih terorganisir, efisien, dan mudah dipelihara.
Apa perbedaan antara CQRS dan Event Sourcing?
CQRS memisahkan operasi baca dan tulis, sedangkan Event Sourcing mencatat semua perubahan sebagai urutan event.
Apa itu 'Saga Pattern'?
Itu adalah cara untuk mengelola transaksi yang melibatkan beberapa service, sehingga semuanya selesai atau dibatalkan dengan benar, meskipun ada satu bagian yang gagal.
Detail
Deskripsi asli dari pembuat
Reference document for monopoly patterns.
Popularitas
- Bintang GitHub
- 48k
- Peringkat
- #5233
- Lisensi
- MIT
- Diperbarui
- 15/10/2026
Komentar
- β¦
Skill lain dari repositori ini
00-andruia-consultant
48kMembantu agent Anda memulai atau meningkatkan proyek AI. Agent menganalisis kode, menyarankan tools, dan membuat rencana aksi dalam bahasa Spanyol.
007
48kMemungkinkan agent Anda melakukan audit keamanan dan threat modeling. Berguna untuk melindungi proyek dari serangan dan celah keamanan.
10-andruia-skill-smith
48kMembantu agent Anda membuat atau meningkatkan tools AI. Agent mendefinisikan cara kerja tools, menulis dokumentasi, dan memvalidasi strukturnya.
20-andruia-niche-intelligence
48kMemungkinkan agent Anda membuat ringkasan industri tertentu. Berguna untuk memahami konteks, aturan, pola penggunaan, dan risiko proyek dengan sumber terpercaya.
Skill serupa
blucli
394kMembantu agent Anda menemukan, memutar, menjeda, mengelompokkan, dan mengatur volume speaker Bluesound dan NAD lewat perintah blu.
camsnap
394kMembantu agent Anda mengambil foto, klip pendek, atau peristiwa gerakan dari kamera jaringan dan webcam lokal yang sudah Anda atur.
eightctl
394kMembantu agent Anda memeriksa dan mengendalikan perangkat Eight Sleep, termasuk suhu, alarm, dan jadwal tidurnya.