-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Messenger] Move Transports to separate packages #35422
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
Conversation
I would do it the same way as with the Mailer and Notifier in terms of namespaces. That would mean creating aliases between the old and the new namespaces, but I think it's worth. |
I've updated the PR:
Tests passes on all 4 packages. I've been careful and I think I've done everything correct. |
dea28ea
to
e96e55e
Compare
src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpFactory.php
Outdated
Show resolved
Hide resolved
342a1f2
to
cbbd57c
Compare
"symfony/messenger-amqp": "^5.1", | ||
"symfony/messenger-doctrine": "^5.1", | ||
"symfony/messenger-redis": "^5.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these requires kinda defeat the need for separate packages IMHO.
We should not add them IMHO, as we can never remove them because of BC.
Alternatively keep the legacy transport in place, and let the new bridges extend from those meanwhile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can (and will) remove them in 6.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These transports should have been in Bridge namespace in the first place. I moving these now, since we are about to add more transports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so i can require symfony/messenger, while using this new symfony/messenger-amq transport, then updating to 6.0 my transport is removed .. and it crashes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #29229 which triggered me. Nevertheless, maybe we should do it in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct.
Assuming you ignored deprecation messages, the changelog and the UPGRADE docs.
(I just added upgrade docs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
im considering new users, they require symfony/messenger tomorrow and are able to start using the new transports wihout any hint they should actually require it separately.
if we can remove those requires in 6.0 then it's fine, but im worried in Nov 2021 we'll consider it a BC break. In this case, not adding them now would avoid that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you require symfony/messenger
tomorrow and start using the transports, you will get a deprecation warning. The deprecation warnings are actually really nice:
The "Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransportFactory" class is deprecated since Symfony 5.1, use "Symfony\Component\Messenger\Bridge\Doctrine\Transport\DoctrineTransportFactory" instead. The Doctrine transport has been moved to package "symfony/messenger-doctrine" and will not be included by default in 6.0. Run "composer require symfony/messenger-doctrine".
So the deprecation layer is there - and (unless you ignore the deprecation warnings) you'll know to require the individual packages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure @weaverryan? It triggers the deprecation only if you load the legacy class. Which is not the case for a simple usage when you let the Bundle loading the transport (see changes in src/Symfony/Bundle/FrameworkBundle/Resources/config/messenger.xml).
For a migration path shouldn't we:
- let code in
symfony/messenger
- create a class in
symfony/bridge-transport
that reuse the code (trait or extends) (not an issue as the bridge already requiressymfony/messenger
) - update the bundle to use
symfony/bridge-transport
class when exist, and fallback tosymfony/messenger
- trigger a deprecation when people use class from
symfony/messenger
2e52edf
to
bc400dc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just played with this code using our (fairly advanced) SfCasts Messenger tutorial and it worked flawlessly. The deprecation warnings are really nice - each instructing me which package to require to fix the deprecation. I can't test requiring the new packages yet (since they don't exist), but that's easy to try after merge and creating the sub-tree splits.
One missing piece I discussed with Tobias (and he agreed, but for a different PR) is to add code to suggest (with an exception) that you require a specific package if you try to use a "core" transport. We should add that "now" (but in a future PR), though users won't see this message until 6.0 when they try to use a transport that's not installed.
+1 from me - I can't find any issues.
I moved The following does not work: // FILE: old.php
namespace Old;
class_alias(\New\Foo::class, \Old\Foo::class);
if (false) {
class Foo{}
}
// FILE: new.php
namespace New;
class Foo{}
// FILE: index.php
function foo(\Old\Foo $old) {};
// This will break.
foo(new \New\Foo()); We need to move the // FILE: old.php
namespace Old;
// Load the new class
class_exists(\New\Foo::class);
if (false) {
class Foo{}
}
// FILE: new.php
namespace New;
class Foo{}
class_alias(Foo::class, Old\Foo::class);
// FILE: index.php
function foo(\Old\Foo $old) {};
// This will work
foo(new {New\Foo()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The BC layer looks good enough for me.
Thank you.
Thank you for all the reviews and carefully thinking out the BC layer. |
src/Symfony/Bundle/FrameworkBundle/Resources/config/messenger.xml
Outdated
Show resolved
Hide resolved
...Symfony/Component/Messenger/Bridge/AmqpExt/Middleware/RejectRedeliveredMessageMiddleware.php
Outdated
Show resolved
Hide resolved
The transports are currently inside the bridge folder of the symfony/messenger package. But for 6.0 we don't want to include the transports automatically. But I don't see how that is going to work without moving the files again? Shouldn't we create new packages outside the symfony/messenger for this to be equipped for 6.0? Otherwise symfony/messenger is a meta-package like symfony/security used to be, which is not what we want. So ideally some structure like
The problem is only that Core is not part of the messenger namespace and would require some autoloading adaptions for symfony/symfony. Another alternative would be to move the transports to |
For what I understand, we can configure subtreesplit so it works as expected. Just like with the Notifier and Mailer component. So we dont need to move the files again. |
I see. If it works like in mailer that's fine for me. I just think it's not an ideal setup because people will not realize that the Bridges are not part of symfony/messenger from reading the source of symfony/symfony on Github. I also didn't expect that subtree splits delete files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a big fan of the names: why not Amqp
instead of AmqpExt
? Same for Redis. The DSN use redis
and amqp
anyway, so I don't see a good reason to use Ext
in the namespace (and IIRC, we are doing it anywhere else).
Sure. I'll rename it. If we want to support the amqp-lib in a separate transport, it could be named |
The namespace is renamed, and the tests are green. |
267d999
to
2990c8f
Compare
Thank you @Nyholm. |
Thank you for merging and thank you for all reviews. |
This broke BC for the stamps, see #37616 |
--------- | ||
|
||
* Deprecated AmqpExt transport. It has moved to a separate package. Run `composer require symfony/amqp-messenger` to use the new classes. | ||
* Deprecated Doctrine transport. It has moved to a separate package. Run `composer require symfony/doctrine-messenger` to use the new classes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some nitpick. I would rename this one to doctrine-dbal-messenger
. The Doctrine organization has many separate projects related to persistence. This bridge integrates with Doctrine DBAL, not with the whole Doctrine projects (having a single bridge for the whole Doctrine makes the dependency management a pain for symfony/doctrine-bridge
btw, so if we ever have another transport using a different Doctrine project, I'd rather have a separate bridge for it)
…alling symfony/messenger (ogizanagi) This PR was merged into the 5.2-dev branch. Discussion ---------- [Messenger] Don't require doctrine/persistence when installing symfony/messenger | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix #36790 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | N/A As of today, [installing `symfony/messenger` installs `symfony/doctrine-messenger`](https://github.com/symfony/symfony/blob/3867fb2489ef0d07dec4859cf461bb7bcc7618e0/src/Symfony/Component/Messenger/composer.json#L23) as well. Which means adding `doctrine/persistence` as a hard dep of the latest will install it for any user requiring `symfony/messenger` in 5.2. I think it should stay a soft-dependency until we remove `symfony/doctrine-messenger` as a `symfony/messenger` dependency as of Symfony 6.0 (as mentioned in #35422). --- related: #36785 Commits ------- 5c05455 [Messenger] Don't require doctrine/persistence when installing symfony/messenger
I think it is a good idea to have the transports in a separate package. The benefits a many:
This PR will not break BC but it requires to configure subtree split.