crgcode / neviles Goto Github PK
View Code? Open in Web Editor NEWAn Evil Event Store
License: Apache License 2.0
An Evil Event Store
License: Apache License 2.0
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.
Needs a new nuget api key in appveyor
https://ci.appveyor.com/project/CRGCode/neviles/build/0.1.0-alpha77
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.