meteor-space / messaging

Messaging infrastructure for Space applications.
12 stars 2 forks source link

CommandBus middleware #28

Open rhyslbw opened 8 years ago

rhyslbw commented 8 years ago

This is a continuation of the discussion from https://github.com/meteor-space/event-sourcing/issues/41

http://tactician.thephpleague.com/middleware/ https://laravel.com/docs/5.0/bus#command-pipeline

Would a design along these lines cover it @qejk ? Seems to address the ordering issue

rhyslbw commented 8 years ago

So on further review this covers the requirements I see for validation in the Space.eventSourcing.Router such as avoiding duplication, or rerunning application validation as a last layer of protection. As the name implies, this object is infrastructure that simply loads up the instance and passes the message (command or event) through for the EventSourceable to handle. While it seems like this is coupling concerns, it's reasonable since an EventSourceable is already aware of messages since it generates events and can trigger commands. The CQRS pattern enforces state change calls to be an immutable directive that only fails when exceptions occur, so if configuration is needed to maintain business rules, I'd suggest that still happen via [Dependency Injection in the EventSourceable](https://github.com/meteor-space/event-sourcing/pull/52 in the form of a service