Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Messenger] Lazy dependency to the Serializer#26908

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

@sroze
Copy link
Contributor

QA
Branch?master
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#26905
LicenseMIT
Doc PRø

So far, when the serializer was not installed we had the following error message:

In CheckExceptionOnInvalidReferenceBehaviorPass.php line 32:  The service "messenger.adapter.amqp.factory" has a dependency on a non-existent service "messenger.transport.default_encoder".

It will now be:

In Serializer.php line 27:  A Serializer is required to use this Messenger transport. Try running "composer req serializer".

boite reacted with thumbs up emoji
@sroze
Copy link
ContributorAuthor

AppVeyor's failure is unrelated.

publicfunction__construct(SerializerInterface$serializer =null,string$format ='json')
{
if (null ===$serializer) {
thrownew \InvalidArgumentException('A Serializer is required to use this Messenger transport. Try running "composer req serializer".');
Copy link
Member

Choose a reason for hiding this comment

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

req ->require (consistency with other spots)

serializer ->symfony/serializer (I think we don't use the aliases in core... just in case there is no Flex)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Good point. Changed the wording 👍

publicfunction__construct(SerializerInterface$serializer =null,string$format ='json')
{
if (null ===$serializer) {
thrownew \InvalidArgumentException('A Serializer is required to use this Messenger transport. Try running "composer require symfony/serializer".');
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO it's not the responsibility of this class to do that. It should be part of the DI pass, where it was handled before.

Copy link
Contributor

@ogizanagiogizanagiApr 12, 2018
edited
Loading

Choose a reason for hiding this comment

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

I agree. The benefit is that it'd remain a compile-time check. Here it's only at runtime. Also, it's not necessarily the component that is not installed. It may just not be enabled.

@sroze
Copy link
ContributorAuthor

sroze commentedApr 12, 2018 via email

Any idea on how we can achieve such DX in that case? 🤔
On Thu, 12 Apr 2018 at 22:13, Maxime Steinhausser ***@***.***> wrote: ***@***.**** commented on this pull request. ------------------------------ In src/Symfony/Component/Messenger/Transport/Serialization/Serializer.php <#26908 (comment)>: > { + if (null === $serializer) { + throw new \InvalidArgumentException('A Serializer is required to use this Messenger transport. Try running "composer require symfony/serializer".'); I agree. The benefit is that it'd remains a compile-time check. Here it's only at runtime. Also, it's not necessarily the component that is not installed. It may just not be enabled. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#26908 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAxHEZ4x1tIs2oSQFujSeYa3RjdBt8Ajks5tn8N8gaJpZM4TSD7S> .

@ogizanagi
Copy link
Contributor

Can't it be done from the FrameworkExtension by throwing when trying to use the amqp adapter without the Serializer component installed/enabled?

@sroze
Copy link
ContributorAuthor

The thing is that you could use the AMQP adapter without Symfony's Serializer component if you use another encoder/decoder. Maybe we can know it when you wire the default encoder/decoder 🤔

@ogizanagi
Copy link
Contributor

@sroze : 🤔AFAIK, there is no configuration for changing the default encoder/decoder. So when using theamqp adapter in messenger config, you'll use themessenger.adapter.amqp.factory which relies on the default encoder/decoder, requiring the serializer. So, if you want to useamqp with a different encoder/decoder, you'll have to create your own service.

Or perhaps you had in mind making themessenger.transport.default_decoder aliases the way for users to change the decoder for instance? I'm not sure this is the best extension point we could made. (BTW, any reason for these aliases to be public?)

@sroze
Copy link
ContributorAuthor

I think the approach in#26941 is much better. Closing this one.

@srozesroze closed thisApr 16, 2018
sroze added a commit that referenced this pull requestApr 17, 2018
This PR was squashed before being merged into the 4.1-dev branch (closes#26941).Discussion----------[Messenger] Allow to configure the transport| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | ish| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#26900,#26908,#26935| License       | MIT| Doc PR        | øWe allow users to configure the encoder/decoder used by the built-in adapter(s). This also adds the support of configuring the default's encoder/decoder format and context.Commits-------1a3f0bb [Messenger] Allow to configure the transport
@srozesroze deleted the serializer-dependency-more-explicit branchApril 17, 2018 17:01
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@weaverryanweaverryanweaverryan approved these changes

+2 more reviewers

@TobionTobionTobion left review comments

@ogizanagiogizanagiogizanagi left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.1

Development

Successfully merging this pull request may close these issues.

5 participants

@sroze@ogizanagi@weaverryan@Tobion@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp