Code Monkey home page Code Monkey logo

eventsource's Introduction

Go Report

Eventsource

Definition

Event sourcing pattern implemented with a postgresql/coackcroachdb compatible eventstore.

Events, aggregates, snapshots and the full aggregate's current state (last projection based on the last transaction) are persisted using the same transaction.

Commands are not persisted but you still can persist them if needed in another layer.

The package also implement an outbox pattern also persisted in the same transaction.

The ids of the entities are generated using a K-Sortable Unique IDentifier (1 second resolution). The migrations to maintain the postgresql eventstore will be added in a future version. The snapshots does not yet have a proper identifier, this should be added at a later stage; snapshots can be fecthed using the aggregate id and the version, subject to a unique index formed by both.

This version is subject to change and will possibly cause breaking changes.

Postgresql/CoackcroachDB schema definition

The SQL schema is as follow (a migration script will be included at a later stage):

create schema if not exists es;
create schema if not exists projection;

drop table if exists es.snapshots;
drop table if exists es.events;
drop table if exists projection.organizations;

create table if not exists es.events
(
    id                varchar primary key,
    type              varchar,
    occurred_at       timestamptz,
    registered_at     timestamptz,
    aggregate_id      varchar,
    aggregate_type    varchar,
    aggregate_version bigint,
    data              jsonb,
    metadata          jsonb,
    unique (aggregate_id, aggregate_version)
);

create table if not exists es.snapshots
(
    aggregate_id      varchar,
    aggregate_type    varchar,
    aggregate_version bigint,
    taken_at          timestamptz,
    registered_at     timestamptz,
    data              jsonb,
    primary key (aggregate_id, aggregate_version)
);

create table if not exists projection.organizations
(
    id                  varchar primary key,
    name                varchar,
    registration_number varchar,
    vat_number          varchar,
    vat_is_intra_com    varchar,
    country             varchar,
    created_by          varchar,
    updated_at          timestamptz,
    created_at          timestamptz,
    version             bigint,
    registered_at       timestamptz
)

eventsource's People

Contributors

jasseem avatar romain-jeannoutot avatar

Stargazers

Julien Litrico avatar  avatar  avatar Razmik Davoyan avatar Jeremy avatar Cédric Degrelle avatar

Watchers

 avatar

eventsource's Issues

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.