Git Product home page Git Product logo

Comments (2)

yevhen avatar yevhen commented on May 28, 2024

I don't see any problems with having async command hander. It's absolutely valid.

If not, these are couple of workarounds I'm thinking of:

  1. make warehouse a simple service with a synchronous call.
  2. add an extra step with a checking actor
  1. will block thread - bad
  2. you're not awaiting Tell operation - bad, will blow in unpredictable ways

The EventSourcingActor is just a sample. You're free to bend it to the needs of your application. That's why I'm releasing it as just an example, not as part of the core. In fact, copy-pasting it into your codebase and poking it until it fits is highly encouraged 😄

Regarding async command handler. There is a DispatchAsync method that is able to call both sync and async message handlers in a uniform way. You will pay a completely negligible price on wrapping/unwrapping task result for sync handlers but that's just it.

Try this code:

protected override async Task<object> HandleCommand(Command cmd)
{
    var events = (await DispatchAsync<IEnumerable<Event>>(cmd)).ToArray();

    foreach (var @event in events)
        Dispatch(@event);

    return (object) events;
}

from orleankka.

aprooks avatar aprooks commented on May 28, 2024

Sounds good, thank you

from orleankka.

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.