An open API service indexing awesome lists of open source software.

https://github.com/dario-l/ses

SimpleEventStore is a simple event store library for .NET based on rdbms persistance.
https://github.com/dario-l/ses

cqrs cqrs-es event-sourcing event-store event-stream ms-sql-server rdbms sql streams

Last synced: 6 months ago
JSON representation

SimpleEventStore is a simple event store library for .NET based on rdbms persistance.

Awesome Lists containing this project

README

          

**Ses is dead. Long live https://github.com/getmanta/manta **
*...but is still used in production code.*

# SimpleEventStore
![SimpleEventStore](https://img.shields.io/nuget/v/SimpleEventStore) SimpleEventStore

![SimpleEventStore](https://img.shields.io/nuget/v/SimpleEventStore.Abstracts) SimpleEventStore.Abstracts

![SimpleEventStore](https://img.shields.io/nuget/v/SimpleEventStore.Domain) SimpleEventStore.Domain

![SimpleEventStore](https://img.shields.io/nuget/v/SimpleEventStore.MsSql) SimpleEventStore.MsSql

![SimpleEventStore](https://img.shields.io/nuget/v/SimpleEventStore.Subscriptions) SimpleEventStore.Subscriptions

![SimpleEventStore](https://img.shields.io/nuget/v/SimpleEventStore.Subscriptions.MsSql) SimpleEventStore.Subscriptions.MsSql

SimpleEventStore is a simple event store library for .NET based on rdbms persistance.

##### Main goals

- Async all the way down (sync methods also available)
- No external dependencies
- Pluggable persistance storage
- Support optimistic (and pesimistic for special cases) concurrency with conflict resolver mechanism
- Support any kind of serialization through ISerializer interface
- Support any kind of loggers through ILogger interface
- Support up-conversion of events/snapshots to the newest version
- Subscriptions to one or many event stream sources for processmanagers/projections/others (with pluggable stream pollers)
- Built-in implementation for: MS SQL Server, InMemory
- Built-in single-writer pattern for MS SQL Server implementation (Linearizer)

##### Basic example of usage

``` c#
var options = new TransactionOptions {IsolationLevel = IsolationLevel.ReadCommitted};
using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew, options, TransactionScopeAsyncFlowOption.Enabled))
{
var aggregate = new ShoppingCart();
aggregate.AddItem(SequentalGuid.NewGuid(), name: "Product 1", quantity: 3);

var stream = new EventStream(id, aggregate.TakeUncommittedEvents());

// Adding metadata item (key, value)
stream.Metadata = new Dictionary
{
{ "RequestIP", "0.0.0.0" },
{ "User", "John Doe" }
};

var expectedVersion = aggregate.CommittedVersion + stream.Events.Count;
await _store.SaveChangesAsync(aggregate.Id, expectedVersion, stream);

scope.Complete();
}
```

Using repository pattern:
``` c#
// Usually transaction scope will be hidden somewhere in infrastructural part of code
using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew, options, TransactionScopeAsyncFlowOption.Enabled))
{
using (var repo = new SourcedRepo(store))
{
// Open stream and restore aggregate from history
var aggregate = await repo.LoadAsync(id);

aggregate.AddItem(Guid.NewGuid(), "Product 1", 3);

await repo.SaveChangesAsync(aggregate);
}
scope.Complete();
}
```

##### It is working on production already

SimpleEventStore has used in commercial project https://timeharmony.pl already.