Git Product home page Git Product logo

neviles's People

Contributors

crgcode avatar ebyte23 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

ebyte23

neviles's Issues

[RFC] `ProjectionEngine` schema isolated projections

Request for comments.

Based on some learnings I think it would be good for us to add a standard way to project and version projects easily.

The way I've seen this done and works okay is to separate by schema per "projection store/repository".

Obviously depending on the app size this may be overkill but if you are changing you projections at some point it will work all the same.

Basically we'd have something like

    public class ProjectionStoreInformation
    {
        public ProjectionStoreInformation(string name, IEnumerable<Type> eventsProjected)
        {
            Name = name;
            EventsProjected = eventsProjected;
        }

        public string Name { get; }
        public IEnumerable<Type> EventsProjected { get; }
    }


    public interface IProjectionEngine
    {
        Task<bool> Setup();
        Task Catchup();
    }

    public interface IReadEventStore
    {
        IEnumerable<IEventRow> Read(long from = 0, long to = 0);
        IEnumerable<IEventRow> Read(Guid streamId);
        IEnumerable<IEventRow> ReadNewestLimit(Guid streamId, int limit = 50);
    }

    public interface IProjectorLookupStrategy
    {
        IEnumerable<Type> GetRegisteredProjectors();
    }


    public class ProjectionEngine : IProjectionEngine
    {
        // db connection
        // info about projection store
        // eventstream replayer
        // IProjectorLookupStrategy



        private readonly ProjectionStoreInformation _storeInformation;

        public ProjectionEngine(
            ProjectionStoreInformation storeInformation,
            IDbTransaction transaction,
            IReadEventStore eventStoreReader,
            IProjectorLookupStrategy projectorLookupStrategy,
            IFactory factory
            )
        {
            this._storeInformation = storeInformation;
        }

        public Task<bool> Setup()
        {
            // Create Schema
            // cmd.Command = $"CREATE SCHEMA IF NOT EXISTS '{_storeInformation.Name}';
            // Create position table
            //cmd.Command = "CREATE TABLE IF NOT EXISTS \"_position\" (id TEXT PRIMARY KEY, position BIGINT)"
            // Create table for handled/projected events not sure if we really need this
            //cmd.Command = "CREATE TABLE IF NOT EXISTS \"_handled_events\" (event_type TEXT))"
            // insert only only row to position
            //cmd.Command = $"INSERT INTO \"_position\" VALUES ('{_storeInformation.Name}', 0) ON CONFLICT DO NOTHING"

            throw new System.NotImplementedException();
        }


        public Task Catchup()
        {

            // get position

            // read from position next 1000 using eventStoreReader using only events we care about _storeInformation.EventsProjected

            // project loop with commit per position 

            // commit

            throw new System.NotImplementedException();
        }
    }

I'm suggesting we change IReadEventStore to return almost the raw event table as at the moment we are returning aggregate commits which don't really mean anything when we are reading from the store we only care on the commit to the store as we want to keep them together as a commit transaction i'm guessing

This would also allow different implementations more easily of IReadEventStore for say sockets or http etc for more disconnected versions of the reader or if they were different db servers for example.

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.