Releases: oskardudycz/EventSourcing.NetCore
Releases · oskardudycz/EventSourcing.NetCore
Added EventStoreDB E-Commerce initial samples
E-Commerce sample of Event Sourcing with EvenStoreDB
Sample is showing the typical flow of the Event Sourcing app with EventStoreDB.
Prerequisities
- Install git - https://git-scm.com/downloads.
- Install .NET Core 5.0 - https://dotnet.microsoft.com/download/dotnet/5.0.
- Install Visual Studio 2019, Rider or VSCode.
- Install docker - https://docs.docker.com/docker-for-windows/install/.
- Open
ECommerce.sln
solution.
Running
- Go to docker and run:
docker-compose up
. - Wait until all dockers got are downloaded and running.
- You should automatically get:
- Postgres DB running
- PG Admin - IDE for postgres. Available at: http://localhost:5050.
- Login:
[email protected]
, Password:admin
- To connect to server Use host:
postgres
, user:postgres
, password:Password12!
- Login:
- EventStoreDB UI: http://localhost:2113/
- Open, build and run
ECommerce.sln
solution.- Swagger should be available at: http://localhost:5000/index.html
Overview
It uses:
- CQRS with MediatR,
- Stores events from Aggregate method results to EventStoreDB,
- Builds read models using Subscription to
$all
. - Read models are stored as Marten documents.
- App has Swagger and predefined docker-compose to run and play with samples.
Write Model
- Most of the write model infrastructure was reused from other samples,
- Added new project
Core.EventStoreDB
for specific EventStoreDB code, - Added EventStoreDBRepository repository to load and store aggregate state,
- Added separate IProjection interface to handle the same way stream aggregation and materialised projections,
- Thanks to that added dedicated AggregateStream method for stream aggregation
- See sample Aggregate
Read Model
- Read models are rebuilt with eventual consistency using subscribe to all EventStoreDB feature,
- Added hosted service SubscribeToAllBackgroundWorker to handle subscribing to all. It handles checkpointing and simple retries if the connection was dropped.
- Added ISubscriptionCheckpointRepository for handling Subscription checkpointing.
- Added checkpointing to EventStoreDB stream with EventStoreDBSubscriptionCheckpointRepository and dummy in-memory checkpointer InMemorySubscriptionCheckpointRepository,
- Added MartenExternalProjection as a sample how to project with
left-fold
into external storage. Another (e.g. ElasticSearch, EntityFramework) can be implemented the same way.
Tests
- Added sample of unit testing in
Carts.Tests
: - Added sample of integration testing in
Carts.Api.Tests
Other
- Added EventTypeMapper class to allow both convention-based mapping (by the .NET type name) and custom to handle event versioning,
- Added StreamNameMapper class for convention-based id (and optional tenant) mapping based on the stream type and module,
- IoC registration helpers for EventStoreDB configuration,
Trivia
- Docker useful commands
docker-compose up
- start dockersdocker-compose kill
- to stop running dockers.docker-compose down -v
- to clean stopped dockers.docker ps
- for showing running dockersdocker ps -a
- to show all dockers (also stopped)
Updated to Marten v4 alpha
Updated to Marten v4 alpha with revolutionary changes to Event Sourcing projections API.
More details in Pull Request: #38
See also:
Updated to .NET 5
- Updated projects to .NET 5 from .NET Core 3.1
- Updated packages to latest versions
- Changed the private class into public to workaround new changes in Marten related to codegen
- Renamed test class
Task
intoIssue
to workaround Marten issue JasperFx/marten#1647 - Needed to make Aggregates classes public because of current Marten v4 alpha codegen limitation (JasperFx/marten#1655), and .NET limitations dotnet/runtime#12454.
See more in: #32
Added Event Sourced Aggregates implementation for e-commerce sample for Practical Event Sourcing workshop
v2.2.0 Added Order aggregate
Added the initial set of commands and events for e-commerce sample for Practical Event Sourcing workshop
v2.1.0 Added missing SentPackage command
Unified Core architecture components
Unified multiple Core architecture components into projects that are reused acrosss all samples.
Upgraded to NetCore 2.1
#12 - Unification EventStore usage (#14) * Upgraded to .NET core 2.1 * Downgraded version of EntityFramework, because it uses newer version of Npgsql because it collides with Marten * Unified EventStore usage * Ignored Pending events for Client entity framework entity
Upgraded versions of MediatR to 4
Upgraded to newest versions of packages. Breaking changes after upgrade to MediatR 4. Now only Asynchronous handlers are available. Synchronous were removed, and asynchronous were renamed to "regular" eg. IAsyncCommandHandler to AsyncCommandHandler
Added Sample of CQRS with Entity Framework
v0.4.0 Upgraded packages
Upgraded versions of Marten to 2 and MediatR to 3
v0.3.0 Update README.md