Comments (4)
Hi @codeliner!
Thank you for the quick response. Actually, the "onlyWithPreProcessor" feature is what I need to start the migration and to get all event machine functionality on board for the future!
Looking forward to that feature:)
Thanks a lot.
from event-machine.
@ebezdomnikov New release available: https://github.com/proophsoftware/event-machine/releases/tag/v0.21.0
the linked PR contains a new test case and a small addition to Event Machine.
A preprocessor can add a command metadata flag return $command->withAddedMetadata(EventMachine::CMD_METADATA_STOP_DISPATCH, true);
to tell Event Machine that command dispatch should be stopped.
I've also prepared a gist for you. With a custom Flavour you can hook into preprocessor calls and f.e. check if a preprocessor implements a command handler interface (or whatever you want to use). This way you can migrate step by step. Let me know if something is unclear.
from event-machine.
Hey @ebezdomnikov thank you for your request.
Just to make sure: Within your command handlers you want to use ORM baked entities, like Doctrine entities?
The problem is, Event Machine is based on the idea of a functional core
You cannot/should not use I/O related services like an entity repository in the core of the system. To enforce this rule Event Machine does not provide a way to inject services into the domain model. You can only work with so called context providers, which are called beforehand.
That said, the only option I can think of is to provide some kind of alternative command handling.
Event Machine can invoke command preprocessors
. The idea is that a preprocessor can enrich a command with additional information (f.e. specific metadata not sent by the client) before it is passed to the domain model.
We could tell Event Machine to only invoke a command preprocessor but stop right after that. The API would look like this (needs to be added to Event Machine but is an "easy-pick"):
$eventMachine->process(Command::ADD_BUILDING)
->onlyWithPreProcessor(Acme\PreProcessor::class);
What you do within the preprocessor is out of scope of Event Machine. You could even use your own Flavour
so that your command handlers don't need to implement a specific interface and don't need to return anything (a preprocessor normally should return a modified command that is than passed on to an aggregate function).
What do you think? Would that be useful for your case?
from event-machine.
@codeliner Hi!
Thank you very much!!!
from event-machine.
Related Issues (20)
- Move DocumentStore to own repository HOT 5
- Move ImmutableRecord to own repository and use ImmutableObject trait HOT 7
- Consider support for message data types again
- Use PHPStan before release 1.0.0 HOT 3
- Release some of the internals as separate libraries? HOT 3
- Message::get
- Register MessageWrapper HOT 1
- Configurable event stream
- Use ImmutableRecord getters in toArray
- Document limitations of JsonSchema integration HOT 1
- Rm context from cmd and queries in GraphQL context HOT 2
- HTTP endpoints should use PSR-15 HOT 2
- Build messagebox explorer HOT 4
- Roadmap Schema UI HOT 1
- JSON schema validation optimization HOT 2
- Use zend-problem-details for error responses
- ImmutableRecord VOs inside arrays are not converted HOT 7
- ImmutableRecordLogic calls fromInt instead of fromFloat HOT 4
- Use PSR-Logger to collect metrics HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from event-machine.