envato / event_sourcery

A library for building event sourced applications in Ruby
MIT License
84 stars 10 forks source link

Restructuring EventSourcery #102

Closed stevehodgkiss closed 7 years ago

stevehodgkiss commented 7 years ago

Right now pieces of event sourcery feel very bundled together:

I am proposing to change this structure to be like this:

Any thoughts, objections or concerns at this stage? Not sure when I'll get to this but I'm keen to make these improvements.

harukizaemon commented 7 years ago

Like it. Like that EventSourcery is becoming more about the Event Streams. Would we then have a CQRSegregationary(tm)(pat.)?

I wonder if, like Command, AggregateRoot isn't really an EventSource term either and could thus move. My 2c worth: I think of Events as belonging to Streams and AggregateRoots are a mapping on top of those.

stevehodgkiss commented 7 years ago

@harukizaemon yeah I agree, event sourcing can be used without DDD so it would be better to not use those terms in the EventStore aspect of EventSourcery (e.g. use stream_id over aggregate_id in events table etc).

grassdog commented 7 years ago

Makes sense to me. Most event sourcing libraries I've seen use the term stream for what we call an aggregate. That's something we could move towards as well once things are more separated.

mjward commented 7 years ago

Makes sense to me πŸ‘

I'd like to try and minimize these sorts of sweeping changes if we can help it going forward though (now that finance manages 3 x event sourcery apps). If this is something we want to do, we should def do it before open sourcing it πŸ˜„

twe4ked commented 7 years ago

Sounds good :+1:

vonconrad commented 7 years ago

EventSourcery::Postgres EventSourcery::Memory

πŸ‘ given the intent of this restructure.

Move domain abstractions AggregateRoot, Repository to the top level

If the goal is to decouple the event sourced aspects from the CQRS and DDD aspects, then these make no sense in the EventSourcery gem at all.

Perhaps a (yet another) separate gem?

Remove Command and Command::Handler, or move them to a separate gem. EventStore::CQRS?

I don't think EventStore::CQRS makes sense. What does CQRS have to do with an EventStore? Where does that top level namespace even come from? πŸ˜†

If we want separation, I prefer @harukizaemon's suggestion to make it something completely different e.g. CQRSegregationary (name pending). As a user, I'd like to be able to use EventSourcery with or without CQRSegregationary, but I'd also like to be able to use CQRSegregationary without EventSourcery. The CQRS pattern is useful outside of event sourcing as well.

If we still want to make the CQRS and DDD aspects somewhat related to "EventSourcery," I can buy EventSourcery::CQRS and EventSourcery::Aggregates as sub-gems. The former would house the Command/Query handling and the latter would be aggregates and repositories.