Giter Site home page Giter Site logo

Comments (4)

ebezdomnikov avatar ebezdomnikov commented on June 12, 2024 2

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.

codeliner avatar codeliner commented on June 12, 2024 2

@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.

codeliner avatar codeliner commented on June 12, 2024

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.

ebezdomnikov avatar ebezdomnikov commented on June 12, 2024

@codeliner Hi!

Thank you very much!!!

from event-machine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.