Git Product home page Git Product logo

Comments (6)

codeliner avatar codeliner commented on July 24, 2024

See prooph/event-sourcing#3

from event-store.

codeliner avatar codeliner commented on July 24, 2024

#37 is somewhat related. The two requirements can be combined.

The ES adapters should only handle plain arrays (serialized domain events).
The Stream class should provide the possibility to attach a Serializer/Unserializer.
The EventStore should inject a serializer when handling the Stream. Default serializer will be a ProophMessageSerializer but custom implementations are allowed (interface required).
Stream::getEventsAsArrays will use the serializer and Stream::getEvents will use the unserializer (can of course be the same instance)
Generators will work great for the two methods.
An adapter can then f.e. wrap a PDOStatement with an own iterator to convert the table row into the event array structure and then pass the iterator to a new Stream instance. The Stream is returned to the event store and the store uses setter injection to add the serializer and unserializer. Now the outside world can iterate over Stream::getEvents and will get a ready to use custom domain event.
Just keep in mind that a PDOStatement does not provide a rewind functionality in all cases so we have to workaround this (maybe by caching the event arrays in the stream?).
A stream interface is maybe also a good idea so we could allow usage of custom stream implementations. One stream would implement a cache and another one not (f.e. to use the pass through mechanism when upcasting or replaying events).

from event-store.

codeliner avatar codeliner commented on July 24, 2024

@mvriel: prooph/event-store 5.x will have better support for custom domain events. I wrote down a rough idea (see last comment) but now have to think about it in detail to come up with something that can be implemented.

from event-store.

codeliner avatar codeliner commented on July 24, 2024

With prooph/common v3.3 a new Prooph\Common\Messaging\Message interface was introduced.
The event store and all adapters will be adjusted to type hint only this interface in the future. So custom domain event implementations need to implement the interface but no longer extend a abstract class. That is the best compromise we can make between duck typing (working with plain PHP arrays only) and a strong coupling (extend an abstract class).

from event-store.

codeliner avatar codeliner commented on July 24, 2024

Removed BC break label because Prooph\Common\Messaging\DomainMessage implements the new interface and can therefor be handled by the event store without adjustments.

from event-store.

codeliner avatar codeliner commented on July 24, 2024

Closed with #52

from event-store.

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.