ThreeDotsLabs / watermill

Building event-driven applications the easy way in Go.
https://watermill.io
MIT License
7.46k stars 400 forks source link

Event Sourcing Completeness #155

Closed yordis closed 6 months ago

yordis commented 5 years ago

Event Sourcing Completeness

As of today, we have a fantastic infrastructure to build a complete Event Sourced system with few components.

And we have few components related to Event Sourcing following the CQRS docs.

However, I would like to track the completeness of Watermill based on what you are trying to accomplish.

Completeness could mean either it supports the feature with some level of abstraction and/or has some documentation about it helping to implement by themselves.

These are some notes of what I think the completeness list would be, but feel free to send feedback about it, I am more interested in starting a discussion and have a thread for it.

Commands

Events

Extra

Also, add some extra abstractions or documentation, helping people to deal with common use cases.

Aggregates

Process Manager

Saga

Saga: distribution of multiple workflows across multiple systems, each providing a path (fork) of compensating actions if any of the steps in the workflow fails.

Read Model Projection

Thoughts?

roblaszczak commented 5 years ago

Commands

Events

Extra

Also, add some extra abstractions or documentation, helping people to deal with common use cases.

Aggregates

Process Manager

Saga

Read Model Projection

screwyprof commented 3 years ago

@yordis, @roblaszczak

I played around with CQRS/ES in go some time ago. Here's an example of a very naive implementation: https://github.com/screwyprof/cqrs/blob/master/examples/bank/bank_test.go

I'm planning to try to use sql-pubsub to run this example. The reason I'm mentioning it is that you may find useful the way I implemented the Aggregate https://github.com/screwyprof/cqrs/tree/master/pkg/cqrs/aggregate. In this case your Domain entities won't depend on infrastructure. Here's an example https://github.com/screwyprof/cqrs/blob/master/examples/bank/pkg/domain/account/account.go

mirusky commented 3 years ago

Hey @yordis @screwyprof @roblaszczak let's talk more about it.

I'm using the watermill in some personal projects and It's so powerful and simple. But as @yordis mentioned there is some things that could have some abstraction and/or has some documentation. For me Aggregates is the difficult thing to newbies in ES to understand and use, so if some support is provided it will be nice.

screwyprof commented 3 years ago

Hey @mirusky . If we were to discuss the CQRS/EventSourcing/DDD and Aggregates in particular it would be a very long discussion. A lot of books have writen on the subject. I'd recomment to start with the following:

In a nutshell:

mirusky commented 3 years ago

Actually I'm more interested in some kind of implementation, I know that an Aggregate should put "component" logic together and be responsable for track the state of the aggregate.

For example

In my conception, aggregate receives commands / execute business associated actions ( eg. methods item.ChangeName("newName") ) and then creates events. So thinking about the watermill ecosystem how it could be implemented ? Since there no way to handle multiple events/commands at once.