EventSourcing.NetCore:.NET 中事件溯源的示例和教程

  • U8_609198
  • 126.7MB
  • zip
  • 0
  • VIP专享
  • 0
  • 2022-04-04 02:30
EventSourcing.NetCore 有关 .NET Core 中的事件溯源的教程、实用示例和其他资源。 5. 样品 6. 自定进度的培训套件 7. 文章 8. 活动商店 - Marten 9. 消息总线(用于处理命令、查询、事件)- MediatR 10. CQRS(命令查询职责分离) 11. 帮助您入门的 NuGet 包。 12. 其他资源 12.1 简介 12.2 生产中的事件溯源 12.3 预测 12.4 快照 12.5 版本控制 12.6 存储 12.7 设计与建模 12.8 GDPR 12.9 冲突检测 12.10 函数式编程 12.12 测试 12.13 CQRS 12.14 工具 12.15 事件溯源与消息传递 12.15 事件处理 12.16 分布式进程 12.17 领域驱动设计 12.18 建筑周刊 1. 事件溯源 1.1 什么是事件溯源? 事
[![Twitter Follow](]( [![Join the chat at](]( ![Github Actions]( [![blog](]( # EventSourcing.NetCore Tutorial, practical samples and other resources about Event Sourcing in .NET Core. - [EventSourcing.NetCore](#eventsourcingnetcore) - [1. Event Sourcing](#1-event-sourcing) - [1.1 What is Event Sourcing?](#11-what-is-event-sourcing) - [1.2 What is Event?](#12-what-is-event) - [1.3 What is Stream?](#13-what-is-stream) - [1.4 Event representation](#14-event-representation) - [1.5 Event Storage](#15-event-storage) - [1.6 Retrieving the current state from events](#16-retrieving-the-current-state-from-events) - [2. Support](#2-support) - [3. Prerequisites](#3-prerequisites) - [4. Tools used](#4-tools-used) - [5. Samples](#5-samples) - [6. Self-paced training Kit](#6-self-paced-training-kit) - [7. Articles](#7-articles) - [8. Event Store - Marten](#8-event-store---marten) - [9. Message Bus (for processing Commands, Queries, Events) - MediatR](#9-message-bus-for-processing-commands-queries-events---mediatr) - [10. CQRS (Command Query Responsibility Separation)](#10-cqrs-command-query-responsibility-separation) - [11. NuGet packages to help you get started.](#11-nuget-packages-to-help-you-get-started) - [12. Other resources](#12-other-resources) - [12.1 Introduction](#121-introduction) - [12.2 Event Sourcing on production](#122-event-sourcing-on-production) - [12.3 Projections](#123-projections) - [12.4 Snapshots](#124-snapshots) - [12.5 Versioning](#125-versioning) - [12.6 Storage](#126-storage) - [12.7 Design & Modeling](#127-design--modeling) - [12.8 GDPR](#128-gdpr) - [12.9 Conflict Detection](#129-conflict-detection) - [12.10 Functional programming](#1210-functional-programming) - [12.12 Testing](#1212-testing) - [12.13 CQRS](#1213-cqrs) - [12.14 Tools](#1214-tools) - [12.15 Event Sourcing vs Messaging](#1215-event-sourcing-vs-messaging) - [12.15 Event processing](#1215-event-processing) - [12.16 Distributed processes](#1216-distributed-processes) - [12.17 Domain Driven Design](#1217-domain-driven-design) - [12.18 Architecture Weekly](#1218-architecture-weekly) ## 1. Event Sourcing ### 1.1 What is Event Sourcing? Event Sourcing is a design pattern in which results of business operations are stored as a series of events. It is an alternative way to persist data. In contrast with state-oriented persistence that only keeps the latest version of the entity state, Event Sourcing stores each state change as a separate event. Thanks for that, no business data is lost. Each operation results in the event stored in the database. That enables extended auditing and diagnostics capabilities (both technically and business-wise). What's more, as events contains the business context, it allows wide business analysis and reporting. In this repository I'm showing different aspects, patterns around Event Sourcing. From the basic to advanced practices. Read more in my articles: - 📝 [How using events helps in a teams' autonomy]( - 📝 [When not to use Event Sourcing?]( ### 1.2 What is Event? Events, represent facts in the past. They carry information about something accomplished. It should be named in the past tense, e.g. _"user added"_, _"order confirmed"_. Events are not directed to a specific recipient - they're broadcasted information. It's like telling a story at a party. We hope that someone listens to us, but we may quickly realise that no one is paying attention. Events: - are immutable: _"What has been seen, cannot be unseen"_. - can be ignored but cannot be retracted (as you cannot change the past). - can be interpreted differently. The basketball match result is a fact. Winning team fans will interpret it positively. Losing team fans - not so much. Read more in my articles: - 📝 [What's the difference between a command and an event?]( - 📝 [Events should be as small as possible, right?]( ### 1.3 What is Stream? Events are logically grouped into streams. In Event Sourcing, streams are the representation of the entities. All the entity state mutations ends up as the persisted events. Entity state is retrieved by reading all the stream events and applying them one by one in the order of appearance. A stream should have a unique identifier representing the specific object. Each event has its own unique position within a stream. This position is usually represented by a numeric, incremental value. This number can be used to define the order of the events while retrieving the state. It can be also used to detect concurrency issues. ### 1.4 Event representation Technically events are messages. They may be represented, e.g. in JSON, Binary, XML format. Besides the data, they usually contain: - **id**: unique event identifier. - **type**: name of the event, e.g. _"invoice issued"_. - **stream id**: object id for which event was registered (e.g. invoice id). - **stream position** (also named _version_, _order of occurrence_, etc.): the number used to decide the order of the event's occurrence for the specific object (stream). - **timestamp**: representing a time at which the event happened. - other metadata like `correlation id`, `causation id`, etc. Sample event JSON can look like: ```json { "id": "e44f813c-1a2f-4747-aed5-086805c6450e", "type": "invoice-issued", "streamId": "INV/2021/11/01", "streamPosition": 1, "timestamp": "2021-11-01T00:05:32.000Z", "data": { "issuedTo": { "name": "Oscar the Grouch", "address": "123 Sesame Street" }, "amount": 34.12, "number": "INV/2021/11/01", "issuedAt": "2021-11-01T00:05:32.000Z" }, "metadata": { "correlationId": "1fecc92e-3197-4191-b929-bd306e1110a4", "causationId": "c3cf07e8-9f2f-4c2d-a8e9-f8a612b4a7f1" } } ``` ### 1.5 Event Storage Event Sourcing is not related to any type of storage implementation. As long as it fulfils the assumptions, it can be implemented having any backing database (relational, document, etc.). The state has to be represented by the append-only log of events. The events are stored in chronological order, and new events are appended to the previous event. Event Stores are the databases' category explicitly designed for such purpose. Read more in my article: - 📝 [What if I told you that Relational Databases are in fact Event Stores?]( ### 1.6 Retrieving the current state from events In Event Sourcing, the state is stored in events. Events are logically grouped into streams. Streams can be thought of as the entities' representation. Traditionally (e.g. in relational or document approach), each entity is stored as a separate record. | Id | IssuerName | IssuerAddress | Amount | Number | IssuedAt | | -------- | ---------------- | ----------------- | ------ | -------------- | ---------- | | e44f813c | Oscar the Grouch | 123 Sesame Street | 34.12 | INV/2021/
    • hbase 分布式存储
    • Ceph分布式存储学习指南
    • 分布式存储FastDFS
    • minio分布式存储
    • ceph分布式存储实战
    • Ceph分布式存储实战mobi版
    • Ceph分布式存储实战
      , 第9章 介绍Ceph分布式存储的硬件选型、性能调优与测试。, 第10章 剖析CRUSH的结构,并给出二副本设计、SSD与SATA混合场景下的磁盘组织方案。, 第11章 详细讲解缓冲池、纠删码的原理与部署,以及纠删码的应用。,...
    • Ceph 分布式存储实战
    • Ceph分布式存储学习指南
    • 大规模分布式存储系统