GithubHelp home page GithubHelp logo

Comments (3)

grrtrr avatar grrtrr commented on May 18, 2024

Thank you for sharing this. This idea seemed neat to me and so I had it copied in one of my projects.

After using it for a while, I ended up merging both handlers,

  • it was more straightforward to do the event-filtering (EventMatcher) at the top of the EventHandler,
  • it would return before any shared resources (locks) needed to be taken,
  • having to maintain 2 functions per event greatly increased the amount of duplicate code.

Unless there are huge performance considerations (which I doubt, since go makes running many thousands of goroutines at the same time possible), I found it led to a simpler overall design.

from eventhorizon.

maxekman avatar maxekman commented on May 18, 2024

Glad it could help! I would love to hear more about your implementation, maybe you can show an example in a gist?

from eventhorizon.

grrtrr avatar grrtrr commented on May 18, 2024

This is in magicbus,

  • an event is a directed message (Source() -> Dest(), it is possible to make Source() optional);
  • the EventHandler both
    • filters events by relevance and
    • processes them, as per above comment.

There are 2 ways to process events:

  • for Aggregates, these are multiplexed with Commands (i.e. at most 1 Command or Event is being processed at any time), as per Actor "serialized code" principle;
  • everything else (e.g. loggers, writers) can subscribe as Observer, which means immediate notification.

(Aggregates only get the events whose Dest() matches the AggregateID, and only if they implement the optional EventHandler interface).

from eventhorizon.

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.