用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/mikailustuner/OmniRule --skill event-driven-patterns命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Bun runtime: HTTP server, file I/O, SQLite, test runner, package manager, bundler — all-in-one JS toolchain.
Clerk: Drop-in auth UI, Organizations, User management, JWT templates, webhooks, Next.js middleware integration.
Gelişmiş masaüstü, tarayıcı ve işletim sistemi kontrol yeteneği. Görsel (koordinat tabanlı) fare/klavye otomasyonu, DOM manipülasyonu, pencere yönetimi, gelişmiş dosya, ağ ve süreç yönetimini kapsar.
基于 SOC 职业分类
正在显示 SKILL.md
| name | event-driven-patterns |
| description | Event-driven: Event sourcing, CQRS, event patterns, choreography vs orchestration. |
| triggers | {"keywords":["event","emit","subscribe","pub/sub","event bus","event sourcing","CQRS","choreography"]} |
| auto_load_when | Designing event-driven systems |
| agent | infra-specialist |
| tools | ["Read","Write","Bash"] |
Focus: Events, commands, event sourcing
When event-driven makes sense:
├── Multiple subsystems need same data
│ └── Orders affect inventory, notifications, analytics
│ └── Each service owns its data
│
├── Loose coupling required
│ └── Services shouldn't call each other directly
│ └── Teams work independently
│
├── Real-time reactions needed
│ └── Notifications, dashboards, sync
│ └── Users see updates immediately
│
├── Audit trail important
│ └── Every change recorded
│ └── Replay for debugging
│
└── Scalability needed
└── Handle burst traffic
└── Decouple producers from consumers
When NOT to use:
├── Simple CRUD app
│ └── Direct database access is simpler
│
├── Strong consistency required
│ └── Eventual consistency issues
│ └── Use synchronous when can't lose data
│
├── Small team
│ └── Complexity overhead not worth it
│
└── Debugging difficult
└── Hard to trace event chains
Event types:
├── Domain events
└── Something happened in domain
└── Orders: OrderPlaced, OrderShipped
└── Meaningful to business
│
├── Integration events
└── Cross-service communication
└── OrderPlaced → NotifyCustomer
└── Technical, not business
│
└── Commands
└── Intent to do something
└── Expects response/action
└── Not an event, a request
Event structure:
├── Event type: what happened
├── Payload: data about event
├── Metadata: timestamp, source, correlation ID
└── Event ID: unique identifier
When to use event sourcing:
├── Need complete audit trail
│ └── Every change stored as event
│ └── Can replay to any point
│
├── Complex state changes
│ └── State derived from event history
│ └── Shopping cart, workflow engines
│
├── Temporal queries
│ └── What was state at time T?
│ └── Reports, analytics, debugging
│
└── Long-running processes
└── Saga, workflows
└── Can resume from checkpoint
Challenges:
├── Learning curve for team
├── Event schema evolution (versioning)
├── Snapshotting for performance
└── Storage size over time
When to use CQRS:
├── Read and write patterns differ
│ └── Writes: complex validation
│ └── Reads: multiple views, aggregations
│
├── Different scaling needs
│ └── Many more reads than writes
│ └── Scale read replicas independently
│
├── Multiple read models
│ └── Same data, different formats
│ └── Product: list view, detail view, admin view
│
└── Performance critical
└── Optimized read paths
└── Denormalized for queries
Implementation:
├── Write side: normalized model
├── Read side: optimized projections
├── Sync: events update read models
└── Eventually consistent
Choreography (decentralized):
├── Each service knows its job
│ └── Orders: emit OrderPlaced
│ └── Inventory: listens, updates stock
│ └── Notifications: listens, sends email
│
├── Pros: loose coupling, independent
├── Cons: hard to track flow, debugging
└── Use when: simple flows, few services
Orchestration (centralized):
├── Orchestrator directs the flow
│ └── OrderService coordinates
│ └── Calls Inventory, then Notifications
│
├── Pros: clear flow, easier debugging
├── Cons: orchestrator is bottleneck
└── Use when: complex flows, need control
Why idempotency matters:
├── Events can be delivered multiple times
├── Network failures cause retries
└── Must handle duplicate events
How to achieve:
├── Event ID tracking
└── Store processed event IDs
└── Skip if already processed
│
├── Natural idempotency
└── Same input = same output
└── "Set status to shipped" is idempotent
│
└── Deduplication table
└── Store event ID + result
└── Fast lookup for duplicates
❌ Event consumers with direct coupling to producers
✅ Events via broker (Kafka/SNS/EventBridge) — producer never calls consumer
❌ Events with no schema contract (free-form JSON)
✅ Schema registry (Confluent/Glue) or Zod schema for every event type
❌ Event handlers that throw and cause infinite retry loops
✅ Bounded retry + dead letter queue; separate poison pill handling
❌ Choreography only — no visibility into multi-step workflows
✅ Add distributed tracing correlation ID across all event hops
❌ Mutable events — changing an event after publish
✅ Events are immutable facts in the past; append-only log
| Pattern | When | Complexity |
|---|---|---|
| Choreography | Loose coupling, simple flows | Low |
| Orchestration | Complex workflows, visibility | Medium |
| Saga | Distributed transaction rollback | High |
| Event sourcing | Full audit trail | High |
| CQRS + events | Read/write separation | High |
| Broker | Throughput | Durability |
|---|---|---|
| Kafka | Very high | Durable replay |
| RabbitMQ | High | Configurable |
| SNS/SQS | High | Managed |
| EventBridge | Medium | Managed |