minor #32078 [Messenger] make all stamps final and mark stamp not meant to be sent (Tobion)

This PR was merged into the 4.4 branch.

Discussion
----------

[Messenger] make all stamps final and mark stamp not meant to be sent

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets |
| License       | MIT
| Doc PR        |

Some newer stamps were already final. This makes all of them final. Also marks all stamps that are not meant to be sent using the new `NonSendableStampInterface`. This makes it easier to see which stamps are actually important and required to persist in a queue for certain functionality, like the `BusNameStamp` for the `RoutableMessageBus`

Commits
-------

013904b081 [Messenger] make all stamps final and mark stamp not meant to be sent
This commit is contained in:
Tobias Schultze 2019-06-24 23:33:22 +01:00
commit 8124159052
10 changed files with 22 additions and 20 deletions

View File

@ -18,7 +18,7 @@ namespace Symfony\Component\Messenger\Stamp;
* *
* @author Ryan Weaver <ryan@symfonycasts.com> * @author Ryan Weaver <ryan@symfonycasts.com>
*/ */
class BusNameStamp implements StampInterface final class BusNameStamp implements StampInterface
{ {
private $busName; private $busName;

View File

@ -16,7 +16,7 @@ namespace Symfony\Component\Messenger\Stamp;
* *
* @experimental in 4.3 * @experimental in 4.3
*/ */
class DelayStamp implements StampInterface final class DelayStamp implements StampInterface
{ {
private $delay; private $delay;

View File

@ -20,6 +20,6 @@ namespace Symfony\Component\Messenger\Stamp;
* *
* @author Tobias Nyholm <tobias.nyholm@gmail.com> * @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/ */
class DispatchAfterCurrentBusStamp implements StampInterface final class DispatchAfterCurrentBusStamp implements NonSendableStampInterface
{ {
} }

View File

@ -17,7 +17,11 @@ use Symfony\Component\Messenger\Handler\HandlerDescriptor;
* Stamp identifying a message handled by the `HandleMessageMiddleware` middleware * Stamp identifying a message handled by the `HandleMessageMiddleware` middleware
* and storing the handler returned value. * and storing the handler returned value.
* *
* This is used by synchronous command buses expecting a return value and the retry logic
* to only execute handlers that didn't succeed.
*
* @see \Symfony\Component\Messenger\Middleware\HandleMessageMiddleware * @see \Symfony\Component\Messenger\Middleware\HandleMessageMiddleware
* @see \Symfony\Component\Messenger\HandleTrait
* *
* @author Maxime Steinhausser <maxime.steinhausser@gmail.com> * @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
* *

View File

@ -25,7 +25,7 @@ use Symfony\Component\Messenger\Middleware\SendMessageMiddleware;
* *
* @experimental in 4.3 * @experimental in 4.3
*/ */
final class ReceivedStamp implements StampInterface final class ReceivedStamp implements NonSendableStampInterface
{ {
private $transportName; private $transportName;

View File

@ -19,7 +19,7 @@ use Symfony\Component\Messenger\Envelope;
* *
* @experimental in 4.3 * @experimental in 4.3
*/ */
class RedeliveryStamp implements StampInterface final class RedeliveryStamp implements StampInterface
{ {
private $retryCount; private $retryCount;
private $senderClassOrAlias; private $senderClassOrAlias;

View File

@ -20,7 +20,7 @@ namespace Symfony\Component\Messenger\Stamp;
* *
* @experimental in 4.3 * @experimental in 4.3
*/ */
final class SentStamp implements StampInterface final class SentStamp implements NonSendableStampInterface
{ {
private $senderClass; private $senderClass;
private $senderAlias; private $senderAlias;

View File

@ -18,7 +18,7 @@ namespace Symfony\Component\Messenger\Stamp;
* *
* @experimental in 4.3 * @experimental in 4.3
*/ */
class SentToFailureTransportStamp implements StampInterface final class SentToFailureTransportStamp implements StampInterface
{ {
private $originalReceiverName; private $originalReceiverName;

View File

@ -18,7 +18,7 @@ namespace Symfony\Component\Messenger\Stamp;
* *
* @experimental in 4.3 * @experimental in 4.3
*/ */
class TransportMessageIdStamp implements StampInterface final class TransportMessageIdStamp implements StampInterface
{ {
private $id; private $id;

View File

@ -55,9 +55,8 @@ class EnvelopeTest extends TestCase
{ {
$envelope = new Envelope(new DummyMessage('dummy'), [ $envelope = new Envelope(new DummyMessage('dummy'), [
new ReceivedStamp('transport1'), new ReceivedStamp('transport1'),
new DelayStamp(5000), new DummyExtendsFooBarStamp(),
new DummyExtendsDelayStamp(5000), new DummyImplementsFooBarStamp(),
new DummyImplementsFooBarStampInterface(),
]); ]);
$envelope2 = $envelope->withoutStampsOfType(DummyNothingImplementsMeStampInterface::class); $envelope2 = $envelope->withoutStampsOfType(DummyNothingImplementsMeStampInterface::class);
@ -66,12 +65,11 @@ class EnvelopeTest extends TestCase
$envelope3 = $envelope2->withoutStampsOfType(ReceivedStamp::class); $envelope3 = $envelope2->withoutStampsOfType(ReceivedStamp::class);
$this->assertEmpty($envelope3->all(ReceivedStamp::class)); $this->assertEmpty($envelope3->all(ReceivedStamp::class));
$envelope4 = $envelope3->withoutStampsOfType(DelayStamp::class); $envelope4 = $envelope3->withoutStampsOfType(DummyImplementsFooBarStamp::class);
$this->assertEmpty($envelope4->all(DelayStamp::class)); $this->assertEmpty($envelope4->all(DummyImplementsFooBarStamp::class));
$this->assertEmpty($envelope4->all(DummyExtendsDelayStamp::class)); $this->assertEmpty($envelope4->all(DummyExtendsFooBarStamp::class));
$envelope5 = $envelope4->withoutStampsOfType(DummyFooBarStampInterface::class); $envelope5 = $envelope3->withoutStampsOfType(DummyFooBarStampInterface::class);
$this->assertEmpty($envelope5->all(DummyImplementsFooBarStampInterface::class));
$this->assertEmpty($envelope5->all()); $this->assertEmpty($envelope5->all());
} }
@ -118,15 +116,15 @@ class EnvelopeTest extends TestCase
} }
} }
class DummyExtendsDelayStamp extends DelayStamp
{
}
interface DummyFooBarStampInterface extends StampInterface interface DummyFooBarStampInterface extends StampInterface
{ {
} }
interface DummyNothingImplementsMeStampInterface extends StampInterface interface DummyNothingImplementsMeStampInterface extends StampInterface
{ {
} }
class DummyImplementsFooBarStampInterface implements DummyFooBarStampInterface class DummyImplementsFooBarStamp implements DummyFooBarStampInterface
{
}
class DummyExtendsFooBarStamp extends DummyImplementsFooBarStamp
{ {
} }