Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add symfony/messenger recipe #395

Merged
12 commits merged into from May 16, 2018
Merged

Add symfony/messenger recipe #395

12 commits merged into from May 16, 2018

Conversation

sroze
Copy link
Contributor

@sroze sroze commented Mar 27, 2018

Q A
License MIT

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request does not pass validation.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request does not pass validation.

@sroze
Copy link
Contributor Author

sroze commented Mar 27, 2018

I guess the review is invalid because obviously, the tag does not exist 🤔

"env": {
"MESSENGER_ADAPTER_DSN": "amqp://guest:guest@localhost:5672/%2f/messages"
},
"aliases": ["messenger", "amqp"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also add "messaging" alias, WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about command_bus too? Even if that's a bit reductive considering the wider component scope, that might be a good way to discover it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it: when making presentations about flex & hexagonal architecture, it's always badass to say "We need a command bus, so let's do composer req command_bus 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about "messaging" tbh. command-bus might be better as a meta-package (or other package), which will use the Messenger and auto-enable specific middlewares for command buses (see here)

"env": {
"MESSENGER_ADAPTER_DSN": "amqp://guest:guest@localhost:5672/%2f/messages"
},
"aliases": ["messenger", "amqp"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about command_bus too? Even if that's a bit reductive considering the wider component scope, that might be a good way to discover it.

"config/": "%CONFIG_DIR%/"
},
"env": {
"MESSENGER_ADAPTER_DSN": "amqp://guest:guest@localhost:5672/%2f/messages"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we really provide this env var value by default? If there is no need for an adapter at first, can't we set it in the recipe to have null as default and add a message explaining how to tweak it in order to use the amqp adapter?

I.e:

# config/packages/messenger.yaml
parameters:
    env(MESSENGER_ADAPTER_DSN): null

or commenting adapters.default: "%env(MESSENGER_ADAPTER_DSN)%"
or providing the MESSENGER_ADAPTER_DSN="amqp://guest:guest@localhost:5672/%2f/messages" var commented by default, as in

"#TRUSTED_PROXIES": "127.0.0.1,127.0.0.2",
.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I quite like the idea of commented lines for the adapters and environment variable as well. I've updated the PR accordingly 👍

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request does not pass validation.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request passes validation.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request passes validation.

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m happy with this recipe. I usually ask for a link to the documentation but we can add that later.

# amqp: "%env(MESSENGER_ADAPTER_DSN)%"

routing:
# Route your messages to the senders...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the mysterious dots at the end ...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason 😄


routing:
# Route your messages to the senders...
# 'App\Message\YourMessage': messenger.sender.amqp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're discussing allowing the short adapter name here - e.g. amqp (and also service id's, of course). If we do that (I want to), it might be simpler to do that before merging the recipe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point. For the records, it's here: symfony/symfony#26909

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request passes validation.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request passes validation.

# amqp: "%env(MESSENGER_ADAPTER_DSN)%"

routing:
# Route your messages to the senders.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would even remove this last dot.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we go, removed (and actually replaced "senders" with "adapters" as it makes more sense now we the shorter name I believe).

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request passes validation.

messenger:
adapters:
# Uncomment the following line to enable an adapter named "amqp"
# amqp: "%env(MESSENGER_ADAPTER_DSN)%"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single quote around the parameter?

},
"env": {
"#MESSENGER_ADAPTER_DSN": "amqp://guest:guest@localhost:5672/%2f/messages"
},
Copy link
Member

@ogizanagi ogizanagi May 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps post-install-output would be a good fit for mentioning the symfony/serializer-pack to start using built-in transport easily.

Copy link
Member

@yceruto yceruto May 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a new symfony/messenger-pack would help to install both also.

Copy link
Contributor Author

@sroze sroze May 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any wording suggestion? :)

Copy link
Member

@ogizanagi ogizanagi May 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<bg=blue;fg=white>              </>
<bg=blue;fg=white> What's next? </>
<bg=blue;fg=white>              </>

  * You're ready to use the Messenger component. You can define your own message buses
    or start using the default one right now by injecting the <info>messenger.bus.default</> service 
    or typehinting <info>Symfony\Component\Messenger\MessageBusInterface</> in your code.
  * If you need to send messages to your broker, you can benefit from the built-in
    amqp transport by: 

    1. Installing the <info>symfony/serializer-pack</>
    2. Uncommenting the <comment> MESSENGER_ADAPTER_DSN</> env var 
       and `framework.messanger.transports.amqp` config
    3. Routing your messages to the amqp sender.

  * <fg=blue>Read</> the documentation at <comment>https://symfony.com/doc/master/components/messenger.html</>

(something like that)

Copy link
Contributor Author

@sroze sroze May 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an amazing idea! Added a very similar content 👍

@@ -0,0 +1,9 @@
framework:
messenger:
adapters:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be renamed to transports

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request passes validation.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request passes validation.

or typehinting <info>Symfony\Component\Messenger\MessageBusInterface</info> in your code.

* If you need to send messages to your broker, you can benefit from the built-in
amqp transport by:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AMQP

* If you need to send messages to your broker, you can benefit from the built-in
amqp transport by:

1. Installing the <info>symfony/serializer-pack</>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing ; at the end (same for the next bullet)


1. Installing the <info>symfony/serializer-pack</>
2. Uncommenting the <comment> MESSENGER_ADAPTER_DSN</> env var
and `framework.messanger.transports.amqp` config
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to remove the backticks. Replace them with <comment>?

amqp transport by:

1. Installing the <info>symfony/serializer-pack</>
2. Uncommenting the <comment> MESSENGER_ADAPTER_DSN</> env var
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra whitespace after <comment>

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request passes validation.

@sroze
Copy link
Contributor Author

sroze commented May 11, 2018

@fabpot updated and added the amqp alias on the symfony/amqp-pack.

"config/": "%CONFIG_DIR%/"
},
"env": {
"#MESSENGER_ADAPTER_DSN": "amqp://guest:guest@localhost:5672/%2f/messages"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The # looks weird here. Keep in mind that this is going to be used for more than the .env file.

I would do something like: "#1": "MESSENGER_ADAPTER_DSN amqp://guest:guest@localhost:5672/%2f/messages", instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you mean by #1 as a key 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use the same here:

"#TRUSTED_PROXIES": "127.0.0.1,127.0.0.2",

should we change it? Not sure to understand what you mean by

Keep in mind that this is going to be used for more than the .env file.

?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using the env config to update phpunit.xml as well. So, using # to mean "comment" is wrong. #1 is a convention to tell the parser that this is a comment, which is then interpreted depending on where we are using the env var.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1 is a convention to tell the parser that this is a comment, which is then interpreted depending on where we are using the env var.

Alright, I'm going to change it that way; though... is it documented somewhere? 🤔

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request passes validation.

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work. Thank you

@Nyholm
Copy link
Member

Nyholm commented May 16, 2018

@symfony-flex-server review please

@fabpot
Copy link
Member

fabpot commented May 16, 2018

@symfony-flex-server review

@sroze
Copy link
Contributor Author

sroze commented May 16, 2018

That bot isn't really listening. 😛

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request passes validation.

@ghost ghost merged commit a2ead7b into symfony:master May 16, 2018
ghost pushed a commit that referenced this pull request May 16, 2018
@sroze sroze deleted the add-messenger-recipe branch May 16, 2018 19:07
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants