Code Monkey home page Code Monkey logo

broadway-eventstore's People

Contributors

akii avatar dbellettini avatar dpsarrou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

broadway-eventstore's Issues

[BUG] Check that we have events to write

In EventStore implementation, the append method always try to write to stream, even if there are no events to write. This causes a 400 error to be thrown, because is trying to write empty content in the stream.

I suggest doing a check in the append method:

if(count($events) > 0) {
            try {
                $this
                    ->eventStore
                    ->writeToStream(
                        $id,
                        new WritableEventCollection($events),
                        $playhead - 1
                    )
                ;
            } catch (WrongExpectedVersionException $e) {
                dd($e->getMessage());
                throw new BroadwayOptimisticLockException($e->getMessage());
            }
        }

@dbellettini what do you think?

Get event version from the eventstore

It's (imho) very wrong to generate the events version (https://github.com/dbellettini/broadway-eventstore/blob/master/src/EventStore/Broadway/BroadwayEventStore.php#L67).

The version is a very important piece when it comes to validate applying them to aggregates as well as resolving conflicts. Instead, the information should come directly from the store. This can be achieved via the URL "aggregate-identifier/version" or, when the EmbedMode::RICH is used, it will be part of the payload.

This is probably also a "downstream" bug/feature that must then be implemented in the eventstore-client. Just checked that I patched the file StreamFeed/Entry to return the event version, so the eventstore-client has no API for this yet (it really should).

If you guys agree, I'd create a PR for both the client and this package getting the event version either from the payload or url.

Events are replayed in the wrong order

The eventstore serves the latest events on page 1. So the stream has to be traversed in the opposite direction, starting from last page to first page.

Will provide a PR this evening.

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.