thephpleague / tactician-bundle

Bundle to integrate Tactician with Symfony projects
MIT License
245 stars 43 forks source link

Update doc on multiple bus config #83

Closed tyx closed 7 years ago

ogizanagi commented 7 years ago

Wild feature idea: what about a simple command_handler placeholder that will be normalized into the proper tactician.commandbus.{bud}.middleware.command_handler service id by the Configuration ?

So you'll just have to write:

tactician:
    commandbus:
        default:    # the "regular" command bus in your application
            middleware:
                - tactician.middleware.validator
                - command_handler # Translated to "tactician.commandbus.default.middleware.command_handler"
        accounting: # the command bus for accounting specific commands
            middleware:
                - tactician.middleware.locking
                - some.middleware.service.to.call.the.remote.accounting.app
                - command_handler # Translated to "tactician.commandbus.accounting.middleware.command_handler"
tyx commented 7 years ago

As the command handler should be the latest we could also remove the necessity to specify it and add it automatically

ogizanagi commented 7 years ago

Agreed.

rosstuck commented 7 years ago

Good changes, thanks for doing this!

Re: auto-adding this... It was discussed a bit in the beginning but the thing is: some folks write custom middleware for executing commands in their own style (in all honesty, we should probably encourage this more rather than adding more config options).

Since the "execution" middlewares (the ones that do the actual handling) are the last ones in the list and don't call any further ahead, it's probably not broken to add one more onto legacy cases but it probably feels a bit sloppy to folks?

What I've thought about for Tactician2 is adding a specific Router object that you pass into command bus constructor (as a separate parameter than the middlewares) and that's the one that does the actual execution and it's always last. We lose kind of that beautiful "everything is a middleware" symmetry in the codebase but it probably becomes a lot easier to understand for folks. We can also let them implement than own routers and those would become easier to dump/debug/wire in standard ways; meaning we could easily port stuff like the Symfony naming conventions to other frameworks with far far less work than it would take right now. (Again, most folks could do this stuff by creating their own execution middleware that they pass the DI container into but very few folks are doing it).

Anyways, this is off topic and all just a spitball right now. We should probably make a separate ticket or take it up on the roadmap issue.

Either way, thanks a ton for this doc improvement, good reaction to the initial support issue. ❤️

tyx commented 7 years ago

adding a specific Router object that you pass into command bus constructor (as a separate parameter than the middlewares) and that's the one that does the actual execution and it's always last. We lose kind of that beautiful "everything is a middleware" symmetry in the codebase but it probably becomes a lot easier to understand for folks

:+1: