Code Monkey home page Code Monkey logo

ses's Introduction

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

SimpleEventStore

SimpleEventStore SimpleEventStore

SimpleEventStore SimpleEventStore.Abstracts

SimpleEventStore SimpleEventStore.Domain

SimpleEventStore SimpleEventStore.MsSql

SimpleEventStore SimpleEventStore.Subscriptions

SimpleEventStore 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
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<string, object>
    {
        { "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:

// 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<ShoppingCart>(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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.