Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Messenger] Add a "in-memory://" transport#29097
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ogizanagi commentedNov 5, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Just a random thought: Isn't a null transport just a special case of amemory transport without any listener? |
Uh oh!
There was an error while loading.Please reload this page.
ogizanagi commentedNov 5, 2018
Note regarding#29097 (comment): that would mean making the MemoryTransport |
src/Symfony/Component/Messenger/Tests/Transport/NullTransportFactoryTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Messenger/Tests/Transport/NullTransportFactoryTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Messenger/Tests/Transport/NullTransportFactoryTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Messenger/Tests/Transport/NullTransportFactoryTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Messenger/Tests/Transport/NullTransportFactoryTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
javiereguiluz commentedNov 7, 2018
@GaryPEGEOT thanks for this contribution! If this is finally merged, please review thelist of Messenger issues andlist of pending Messenger pull requests to see if there are issues/PRs conflicting with this change. If there are not, please open an issue inhttps://github.com/symfony/symfony-docs/issues to track this change. You don't have to provide the docs yourself if you don't want, but this would help us track the change. Thanks! |
sroze left a comment
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.
Except these stylish details to be changed, looks good to me 👍
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
stof commentedMar 20, 2019
If you never flush your MemoryTransport, it would leak memory. So using it instead of a NullTransport looks wrong (having to flush something when you expect it to be a blackhole is not intuitive) |
| */ | ||
| publicfunctionsend(Envelope$envelope):Envelope | ||
| { | ||
| $this->sent[] =$envelope; |
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.
As we accumulate envelopes over time, do we need to implementResetableInterface to flush the envelopes from one request to the next?
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.
ogizanagi commentedMar 21, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
But it's not just a blackhole ( |
sroze commentedMar 23, 2019
@GaryPEGEOT can you implement the |
sroze commentedMar 23, 2019 via email
Indeed, it would make sense. …On Sat, 23 Mar 2019 at 22:48, Gary PEGEOT ***@***.***> wrote: ***@***.**** commented on this pull request. ------------------------------ In src/Symfony/Component/Messenger/Transport/NullTransport.php <#29097 (comment)>: > + } + + /** + * ***@***.***} + */ + public function stop(): void + { + $this->stopped = true; + } + + /** + * ***@***.***} + */ + public function send(Envelope $envelope): Envelope + { + $this->sent[] = $envelope;@sroze <https://github.com/sroze>,@fabpot <https://github.com/fabpot> I've implemented Symfony\Contracts\Service\ResetInterface and I now see that there is an ack an reject method in the Transport interface. Do you think we need to store which message has been ack / nack? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#29097 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAxHEZUH-p7C_wteK6h840k5Nr_c8SPSks5vZkzOgaJpZM4YOsl_> . |
GaryPEGEOT commentedMar 23, 2019
@sroze I added the |
| * | ||
| * @author Gary PEGEOT <garypegeot@gmail.com> | ||
| */ | ||
| class NullTransportimplements TransportInterface, ResetInterface |
ogizanagiMar 23, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
Note implementingResetInterface isn't enough for this to be properly integrated with the framework and stored envelopes to be cleared from one request to the next. The service definition must be tagged withkernel.reset.
But as the service is built using a factory and might use an env var for the DSN, it may not be possible to add the tag conditionally from the extension (compile time). Instead, you could implement ResetInterface on the factory too and keep track of created services to clear them from here (so only the factory will be tagged withkernel.reset).
| * | ||
| * @author Gary PEGEOT <garypegeot@gmail.com> | ||
| */ | ||
| class NullTransportFactoryTestextends \PHPUnit\Framework\TestCase |
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.
maybe worth importing TestCase?use PHPUnit\Framework\TestCase;
fabpot commentedMar 31, 2019
I agree with@ogizanagi that I would not expect a |
sroze commentedMar 31, 2019
|
weaverryan commentedMar 31, 2019
Well, we also have#28746, which is a "memory" transport where the messages are sent on |
sroze commentedMar 31, 2019
I agree it should be the same implementation. Though... it could actually be two DSNs |
GaryPEGEOT commentedMar 31, 2019
Should it be a black-hole and do nothing at all (no storing nor receiving of message) to avoid duplication with memory listener? |
sroze commentedMar 31, 2019
What do you mean? 🤔 |
GaryPEGEOT commentedMar 31, 2019
memorytransport, my bad!, both this transport and the one in#28746 store message in memory, so are kind of duplicate. Should this one donothing instead, ie not storing any message? |
weaverryan commentedMar 31, 2019
I think the idea is this: This one SHOULD store in memory, and be called |
sroze commentedMar 31, 2019
Exactly 👍 |
GaryPEGEOT commentedMar 31, 2019
Renamed to |
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Bundle/FrameworkBundle/Resources/config/messenger.xml OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
| useSymfony\Contracts\Service\ResetInterface; | ||
| /** | ||
| * Transport that stay in memory. Useful for testing purpose. |
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.
stays
fabpot commentedApr 6, 2019
Thank you@GaryPEGEOT. |
…, sroze)This PR was merged into the 4.3-dev branch.Discussion----------[Messenger] Add a "in-memory://" transport| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#29040| License | MIT| Doc PR | TodoAdd a new `InMemoryTransport` for test purpose, usable by starting your DSN by `in-memory://`Commits-------8f8c82e Make the in-memory transport resettablefe75920 Add a "null://" transport
src/Symfony/Component/Messenger/Tests/Transport/InMemoryTransportFactoryTest.phpShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Nyholm left a comment
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.
Thank you
#eu-fossa
Uh oh!
There was an error while loading.Please reload this page.
Add a new
InMemoryTransportfor test purpose, usable by starting your DSN byin-memory://