xtrasmal / TacticianBundle

Symfony2 Bundle for the Tactician library -DEPRECATED / MOVED to
https://github.com/thephpleague/tactician-bundle
5 stars 2 forks source link

Multiple Command Bus support #6

Closed rosstuck closed 9 years ago

rosstuck commented 9 years ago

There's been a lot of offline discussion about supporting multiple command buses more easily. I'm thinking of a syntax like the following:

tactician:
    default: # maps to the default tactician.commandbus service
        method_inflector: "tactician.handler.inflector.handle"
        handler_locator: "tactician.handler.locator.symfony"
        middleware:
            - my.app.custom.middleware
            - tactician.some.standard.middleware1
            - tactician.some.standard.middleware2
    job_queue:  # dynamically creates new service tactician.commandbus.job_queue
        method_inflector: "tactician.handler.inflector.handle"
        handler_locator: "some.custom.one"
        middleware:
            - my.app.custom.middleware
            - tactician.some.standard.middleware3

Questions:

rosstuck commented 9 years ago

On second thought, we really should nest them because we likely want some other 2nd level keys for optional plugin packages, like queuing or doctrine transactions.

rdohms commented 9 years ago

My 2 cents.

rtuin commented 9 years ago

+1 for nesting the bus definitions.

Assuming the the (generated) bus names are in the format of tactician.commandbus.busname I suggest to nest them under "commandbus". Like so:

tactician:
    commandbus:
        default:
            # ...
        job_queue:
            # ...

The method_inflector and handler_locator should not be under these definitions as they are specific to the CommandHandlerMiddleware.

rtuin commented 9 years ago

Should the dynamic buses extend the options set in default or not? (since that refers to an actual command bus instance and not just a generic options bag, that could get confusing. Maybe split default options and default command bus instance)

That could be practical in most cases, but confusing in others. Which default options are we talking about?

rtuin commented 9 years ago

make default a property, and allow us to give any names we wish, but then alias the tactician.commandbus service to the default bus. Allows us to use meaningful names to hint at their uses in the app. (or just assume if there is one, it is the default)

+1 on that!

rtuin commented 9 years ago

FYI: I started working on this one. Don't let it stop the discussion, of course.

rosstuck commented 9 years ago

Sounds good to me, I'm looking forward to @rtuin's version. :smiley:

rdohms commented 9 years ago

Yep, looks like the way to go.

rtuin commented 9 years ago

I've opened a work-in-progress PR here: https://github.com/xtrasmal/TacticianBundle/pull/19

rtuin commented 9 years ago

Since #19 was merged, can someone review the status of this ticket?

xtrasmal commented 9 years ago

Shall we close this now that the support is there?

rdohms commented 9 years ago

:+1: