Files
nexus/wiki/concepts/Event-Sourcing.md
2026-04-21 16:03:27 +08:00

27 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Event Sourcing"
type: concept
tags: [architecture, event-driven, state-management]
---
## Summary
Event Sourcing事件溯源是一种软件架构模式通过存储所有状态变更事件而非仅存储当前状态来重建系统历史。
## Definition
事件溯源将应用状态的所有变更存储为一系列不可变的事件对象。通过重放这些事件,可以重建任意时间点的系统状态。
## Key Principles
- **事件即事实**:状态变更以事件形式持久化,而非覆盖最终状态
- **完整审计日志**:天然具备完整的审计追踪能力
- **时间旅行调试**:可以重放事件序列重现历史状态
- **解耦读写**:写操作存储事件,读操作通过事件投影计算状态
## Relationship to Project State Management
Project State Management 系统将 Event Sourcing 模式应用于项目管理:
- 每个项目事件progress、blocker、decision、pivot作为不可变事件存储
- 项目当前状态通过事件投影计算
- 决策上下文通过查询事件历史恢复
## External Links
- [Event Sourcing Pattern - Martin Fowler](https://martinfowler.com/eaaDev/EventSourcing.html)