Event Store Design

作者 wshobson46891e7e60da无许可证收录于 2026年10月8日更新于 2026年10月8日

Design and implement event stores for event-sourced systems. Use when building event sourcing infrastructure, choosing event store technologies, or implementing event persistence patterns.

AI 生成的概览

指导事件溯源系统的事件存储设计与实现,涵盖架构、技术选型与最佳实践。

功能
该技能为事件溯源应用的事件存储设计提供指导。它讲解只追加流、排序、版本控制、订阅与幂等性等核心概念,比较 EventStoreDB、PostgreSQL、Kafka、DynamoDB 和 Marten 等事件存储技术,并列出最佳实践与常见误区。它指向一个参考文件以获取模板和详细示例。
适用场景
适用于构建事件溯源基础设施、在事件存储技术之间做选择、实现自定义事件存储,或规划事件存储的架构与扩展。也适合优化事件的存储与检索。
运行要求
不含脚本,仅为说明性内容。它引用随附文件 references/details.md 以获取模板和详细示例。无需凭据、软件包或网络访问。

Event Store Design

Comprehensive guide to designing event stores for event-sourced applications.

When to Use This Skill

  • Designing event sourcing infrastructure
  • Choosing between event store technologies
  • Implementing custom event stores
  • Optimizing event storage and retrieval
  • Setting up event store schemas
  • Planning for event store scaling

Core Concepts

1. Event Store Architecture

┌─────────────────────────────────────────────────────┐│                    Event Store                       │├─────────────────────────────────────────────────────┤│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐ ││  │   Stream 1   │  │   Stream 2   │  │   Stream 3   │ ││  │ (Aggregate)  │  │ (Aggregate)  │  │ (Aggregate)  │ ││  ├─────────────┤  ├─────────────┤  ├─────────────┤ ││  │ Event 1     │  │ Event 1     │  │ Event 1     │ ││  │ Event 2     │  │ Event 2     │  │ Event 2     │ ││  │ Event 3     │  │ ...         │  │ Event 3     │ ││  │ ...         │  │             │  │ Event 4     │ ││  └─────────────┘  └─────────────┘  └─────────────┘ │├─────────────────────────────────────────────────────┤│  Global Position: 1 → 2 → 3 → 4 → 5 → 6 → ...     │└─────────────────────────────────────────────────────┘

2. Event Store Requirements

RequirementDescription
Append-onlyEvents are immutable, only appends
OrderedPer-stream and global ordering
VersionedOptimistic concurrency control
SubscriptionsReal-time event notifications
IdempotentHandle duplicate writes safely

Technology Comparison

TechnologyBest ForLimitations
EventStoreDBPure event sourcingSingle-purpose
PostgreSQLExisting Postgres stackManual implementation
KafkaHigh-throughput streamingNot ideal for per-stream queries
DynamoDBServerless, AWS-nativeQuery limitations
Marten.NET ecosystems.NET specific

Templates and detailed worked examples

Full template library and detailed worked examples live in references/details.md. Read that file when you need the concrete templates.

Best Practices

Do's

  • Use stream IDs that include aggregate type - Order-{uuid}
  • Include correlation/causation IDs - For tracing
  • Version events from day one - Plan for schema evolution
  • Implement idempotency - Use event IDs for deduplication
  • Index appropriately - For your query patterns

Don'ts

  • Don't update or delete events - They're immutable facts
  • Don't store large payloads - Keep events small
  • Don't skip optimistic concurrency - Prevents data corruption
  • Don't ignore backpressure - Handle slow consumers

来源与署名

来源:wshobson/agents位于plugins/backend-development/skills/event-store-design提交46891e7

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架