Coder Social home page Coder Social logo

Add async commands about apip-ddd HOT 2 OPEN

javaDeveloperKid avatar javaDeveloperKid commented on June 16, 2024
Add async commands

from apip-ddd.

Comments (2)

yceruto avatar yceruto commented on June 16, 2024
if (!$handledStamps) {
    // async command
    return null;
}

Note that still a normal sync command must meet a handler. By removing the logic exception you'll miss that rule.

The alternative to allow async without losing the sync validation would be:

if (!$handledStamps) {
    if ($envelope->all(SentStamp::class)) {
        // async command
        return null;
    }

    throw new LogicException(sprintf('Message of type "%s" was handled zero times. Exactly one handler is expected when using "%s::%s()".', get_debug_type($envelope->getMessage()), static::class, __FUNCTION__));
}

Checking by SentStamp::class you'll know that the command was at least sent through an async transport.

from apip-ddd.

javaDeveloperKid avatar javaDeveloperKid commented on June 16, 2024

Thank you for your response 👍 However my problem described above is about PHPStan and generics :)

Note that still a normal sync command must meet a handler. By removing the logic exception you'll miss that rule.

I believe allow_no_handlers: false in the bus configuration (this is a default in SF Messenger) will take care of that.

from apip-ddd.

Related Issues (17)

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.