prefix stringlengths 512 512 | suffix stringlengths 256 256 | middle stringlengths 14 229 | meta dict |
|---|---|---|---|
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger;
use Symfony\Component\Messenger\Middleware\MiddlewareInterface;
use Symfony\Component\Messeng... | ewareHandlers = [])
{
if ($middlewareHandlers instanceof \IteratorAggregate) {
$this->middlewareAggregate = $middlewareHandlers;
} elseif (\is_array($middlewareHandlers)) {
$this->middlewareAggregate = new \Array | sageBus implements MessageBusInterface
{
private \IteratorAggregate $middlewareAggregate;
/**
* @param iterable<mixed, MiddlewareInterface> $middlewareHandlers
*/
public function __construct(iterable $middl | {
"filepath": "src/Symfony/Component/Messenger/MessageBus.php",
"language": "php",
"file_size": 2478,
"cut_index": 563,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger;
use Symfony\Component\Messenger\Exception\LogicException;
use Symfony\Component\Messenger\Sta... | e result from the handler returned value.
* This behavior is useful for both synchronous command & query buses,
* the last one usually returning the handler result.
*
* @param object|Envelope $message The message or the message pre-wra | ime Steinhausser <maxime.steinhausser@gmail.com>
*/
trait HandleTrait
{
private MessageBusInterface $messageBus;
/**
* Dispatches the given message, expecting to be handled by a single handler
* and returns th | {
"filepath": "src/Symfony/Component/Messenger/HandleTrait.php",
"language": "php",
"file_size": 2510,
"cut_index": 563,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Messenger\Command;
use Psr\Container\ContainerInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Completion\CompletionInput;
use Symfony\Component\Console\Completion\Com... | ;
/**
* @author Kévin Thérage <therage.kevin@gmail.com>
*/
#[AsCommand(name: 'messenger:stats', description: 'Show the message count for one or more transports')]
class StatsCommand extends Command
{
public function __construct(
private Cont | t\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Messenger\Exception\InvalidArgumentException;
use Symfony\Component\Messenger\Transport\Receiver\MessageCountAwareInterface | {
"filepath": "src/Symfony/Component/Messenger/Command/StatsCommand.php",
"language": "php",
"file_size": 5201,
"cut_index": 716,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Command;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Console\Attribute\AsComma... | their current message')]
class StopWorkersCommand extends Command
{
public function __construct(
private CacheItemPoolInterface $restartSignalCachePool,
) {
parent::__construct();
}
protected function configure(): void
| \SymfonyStyle;
use Symfony\Component\Messenger\EventListener\StopWorkerOnRestartSignalListener;
/**
* @author Ryan Weaver <ryan@symfonycasts.com>
*/
#[AsCommand(name: 'messenger:stop-workers', description: 'Stop workers after | {
"filepath": "src/Symfony/Component/Messenger/Command/StopWorkersCommand.php",
"language": "php",
"file_size": 2094,
"cut_index": 563,
"middle_length": 229
} |
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\EventListener;
use Symfony\Component\EventDispatc... | ope()->last(ErrorDetailsStamp::class);
// Do not append duplicate information
if (null === $previousStamp || !$previousStamp->equals($stamp)) {
$event->addStamps($stamp);
}
}
public static function getSubscribe | implements EventSubscriberInterface
{
public function onMessageFailed(WorkerMessageFailedEvent $event): void
{
$stamp = ErrorDetailsStamp::create($event->getThrowable());
$previousStamp = $event->getEnvel | {
"filepath": "src/Symfony/Component/Messenger/EventListener/AddErrorDetailsStampListener.php",
"language": "php",
"file_size": 1215,
"cut_index": 518,
"middle_length": 229
} |
n Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Messenger\Ev... | _dispatch')) {
return;
}
pcntl_signal_dispatch();
}
public static function getSubscribedEvents(): array
{
if (!\function_exists('pcntl_signal_dispatch')) {
return [];
}
return [ | id
{
if (!\function_exists('pcntl_signal | {
"filepath": "src/Symfony/Component/Messenger/EventListener/DispatchPcntlSignalListener.php",
"language": "php",
"file_size": 977,
"cut_index": 582,
"middle_length": 52
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Com... | nce the retry flow has decided not to
* retry (retries exhausted, unrecoverable exception, or no retry strategy),
* the lock must be released to unblock future messages sharing the same key.
*
* Caveat: a message moved to a failure transport and later | handled message definitively fails.
*
* The {@see \Symfony\Component\Messenger\Middleware\DeduplicateMiddleware}
* keeps the lock held when a handler throws, so that a message still being
* retried cannot be enqueued again. O | {
"filepath": "src/Symfony/Component/Messenger/EventListener/ReleaseDeduplicationLockOnFailureListener.php",
"language": "php",
"file_size": 2534,
"cut_index": 563,
"middle_length": 229
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\EventListener;
use Symfony\Component\EventDispatcher\Ev... | memory usage for accurate measurement of the
// memory usage on a per-message basis.
memory_reset_peak_usage();
$this->collect = true;
}
public function collectAfter(WorkerRunningEvent $event): void
{
if ($even | gmbh.com>
*/
final class ResetMemoryUsageListener implements EventSubscriberInterface
{
private bool $collect = false;
public function resetBefore(WorkerMessageReceivedEvent $event): void
{
// Reset the peak | {
"filepath": "src/Symfony/Component/Messenger/EventListener/ResetMemoryUsageListener.php",
"language": "php",
"file_size": 1372,
"cut_index": 524,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\EventListener;
use Symfony\Component\DependencyInjection\Attribute\A... | ace
{
private int $interval = 1;
private int $count = 0;
public function __construct(
#[Autowire(service: ServicesResetterInterface::class)]
private ResetInterface $servicesResetter,
) {
}
public function setInterv | gEvent;
use Symfony\Component\Messenger\Event\WorkerStoppedEvent;
use Symfony\Contracts\Service\ResetInterface;
/**
* @author Grégoire Pineau <lyrixx@lyrixx.info>
*/
class ResetServicesListener implements EventSubscriberInterf | {
"filepath": "src/Symfony/Component/Messenger/EventListener/ResetServicesListener.php",
"language": "php",
"file_size": 1680,
"cut_index": 537,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Messenger\EventListener;
use Psr\Container\ContainerInterface;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Messenger\Envelope;
use Symfo... | nger\Retry\RetryStrategyInterface;
use Symfony\Component\Messenger\Stamp\DelayStamp;
use Symfony\Component\Messenger\Stamp\RedeliveryStamp;
use Symfony\Component\Messenger\Stamp\SentForRetryStamp;
use Symfony\Component\Messenger\Stamp\StampInterface;
use S | mfony\Component\Messenger\Exception\RecoverableExceptionInterface;
use Symfony\Component\Messenger\Exception\RuntimeException;
use Symfony\Component\Messenger\Exception\UnrecoverableExceptionInterface;
use Symfony\Component\Messe | {
"filepath": "src/Symfony/Component/Messenger/EventListener/SendFailedMessageForRetryListener.php",
"language": "php",
"file_size": 7478,
"cut_index": 716,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\EventListener;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;... | dFailedMessageToFailureTransportListener implements EventSubscriberInterface
{
public function __construct(
private ContainerInterface $failureSenders,
private ?LoggerInterface $logger = null,
private array $failureTransportsByN | ponent\Messenger\Stamp\RedeliveryStamp;
use Symfony\Component\Messenger\Stamp\SentToFailureTransportStamp;
/**
* Sends a rejected message to a "failure transport".
*
* @author Ryan Weaver <ryan@symfonycasts.com>
*/
class Sen | {
"filepath": "src/Symfony/Component/Messenger/EventListener/SendFailedMessageToFailureTransportListener.php",
"language": "php",
"file_size": 3266,
"cut_index": 614,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriber... | te bool $stop = false;
public function onMessageFailed(WorkerMessageFailedEvent $event): void
{
$th = $event->getThrowable();
if ($th instanceof StopWorkerExceptionInterface) {
$this->stop = true;
}
if ( | ption;
use Symfony\Component\Messenger\Exception\StopWorkerExceptionInterface;
/**
* @author Grégoire Pineau <lyrixx@lyrixx.info>
*/
class StopWorkerOnCustomStopExceptionListener implements EventSubscriberInterface
{
priva | {
"filepath": "src/Symfony/Component/Messenger/EventListener/StopWorkerOnCustomStopExceptionListener.php",
"language": "php",
"file_size": 1688,
"cut_index": 537,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\EventListener;
use Psr\Log\LoggerInterface;
use Symfony\Component\Ev... | ction __construct(
private int $maximumNumberOfFailures,
private ?LoggerInterface $logger = null,
) {
if ($maximumNumberOfFailures <= 0) {
throw new InvalidArgumentException('Failure limit must be greater than zero.' | r\Exception\InvalidArgumentException;
/**
* @author Michel Hunziker <info@michelhunziker.com>
*/
class StopWorkerOnFailureLimitListener implements EventSubscriberInterface
{
private int $failedMessages = 0;
public fun | {
"filepath": "src/Symfony/Component/Messenger/EventListener/StopWorkerOnFailureLimitListener.php",
"language": "php",
"file_size": 1808,
"cut_index": 537,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\EventListener;
use Psr\Log\LoggerInterface;
use Symfony\Component\Ev... | ogger = null,
?callable $memoryResolver = null,
) {
$memoryResolver ??= static fn () => memory_get_usage(true);
$this->memoryResolver = $memoryResolver(...);
}
public function onWorkerRunning(WorkerRunningEvent $event): | ion.de>
*/
class StopWorkerOnMemoryLimitListener implements EventSubscriberInterface
{
private \Closure $memoryResolver;
public function __construct(
private int $memoryLimit,
private ?LoggerInterface $l | {
"filepath": "src/Symfony/Component/Messenger/EventListener/StopWorkerOnMemoryLimitListener.php",
"language": "php",
"file_size": 1566,
"cut_index": 537,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\EventListener;
use Psr\Log\LoggerInterface;
use Symfony\Component\Ev... | private int $maximumNumberOfMessages,
private ?LoggerInterface $logger = null,
) {
if ($maximumNumberOfMessages <= 0) {
throw new InvalidArgumentException('Message limit must be greater than zero.');
}
}
| e <samuel.roze@gmail.com>
* @author Tobias Schultze <http://tobion.de>
*/
class StopWorkerOnMessageLimitListener implements EventSubscriberInterface
{
private int $receivedMessages = 0;
public function __construct(
| {
"filepath": "src/Symfony/Component/Messenger/EventListener/StopWorkerOnMessageLimitListener.php",
"language": "php",
"file_size": 1603,
"cut_index": 537,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\EventListener;
use Psr\Cache\CacheItemPoolInterface;
use Psr\Log\Log... | private float $workerStartedAt = 0;
public function __construct(
private CacheItemPoolInterface $cachePool,
private ?LoggerInterface $logger = null,
) {
}
public function onWorkerStarted(): void
{
$this->work | ;
/**
* @author Ryan Weaver <ryan@symfonycasts.com>
*/
class StopWorkerOnRestartSignalListener implements EventSubscriberInterface
{
public const RESTART_REQUESTED_TIMESTAMP_KEY = 'workers.restart_requested_timestamp';
| {
"filepath": "src/Symfony/Component/Messenger/EventListener/StopWorkerOnRestartSignalListener.php",
"language": "php",
"file_size": 1860,
"cut_index": 537,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\EventListener;
use Psr\Log\LoggerInterface;
use Symfony\Component\Ev... | cata@free.fr>
* @author Tobias Schultze <http://tobion.de>
*
* @deprecated since Symfony 8.1, use the "time_limit" worker option instead
*/
class StopWorkerOnTimeLimitListener implements EventSubscriberInterface
{
private float $endTime = 0;
p | ption\InvalidArgumentException;
trigger_deprecation('symfony/messenger', '8.1', '"%s" is deprecated, use the "time_limit" worker option instead.', StopWorkerOnTimeLimitListener::class);
/**
* @author Simon Delicata <simon.deli | {
"filepath": "src/Symfony/Component/Messenger/EventListener/StopWorkerOnTimeLimitListener.php",
"language": "php",
"file_size": 1992,
"cut_index": 537,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Messenger\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Stamp\DelayStamp;
use Symfony\Component\Messenger\Stamp\ReceivedStamp;
use Symfony\Component\Messenger\Stamp\StampInterface;
use Symfo... | ssertSame($dummy, $envelope->getMessage());
$this->assertArrayHasKey(ReceivedStamp::class, $stamps = $envelope->all());
$this->assertSame($receivedStamp, $stamps[ReceivedStamp::class][0]);
}
public function testWithReturnsNewInstan | eTest extends TestCase
{
public function testConstruct()
{
$receivedStamp = new ReceivedStamp('transport');
$envelope = new Envelope($dummy = new DummyMessage('dummy'), [$receivedStamp]);
$this->a | {
"filepath": "src/Symfony/Component/Messenger/Tests/EnvelopeTest.php",
"language": "php",
"file_size": 5519,
"cut_index": 716,
"middle_length": 229
} |
FailedMessageToFailureTransportListener;
use Symfony\Component\Messenger\EventListener\StopWorkerOnMessageLimitListener;
use Symfony\Component\Messenger\Exception\DelayedMessageHandlingException;
use Symfony\Component\Messenger\Exception\HandlerFailedException;
use Symfony\Component\Messenger\Exception\ValidationFailed... | ssenger\Middleware\HandleMessageMiddleware;
use Symfony\Component\Messenger\Middleware\SendMessageMiddleware;
use Symfony\Component\Messenger\Middleware\ValidationMiddleware;
use Symfony\Component\Messenger\Retry\MultiplierRetryStrategy;
use Symfony\Compon | \Messenger\Middleware\AddBusNameStampMiddleware;
use Symfony\Component\Messenger\Middleware\DispatchAfterCurrentBusMiddleware;
use Symfony\Component\Messenger\Middleware\FailedMessageProcessingMiddleware;
use Symfony\Component\Me | {
"filepath": "src/Symfony/Component/Messenger/Tests/FailureIntegrationTest.php",
"language": "php",
"file_size": 24185,
"cut_index": 1331,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Exception\LogicException;
use Sy... | ->expectException(LogicException::class);
$this->expectExceptionMessage('You must provide a "Symfony\Component\Messenger\MessageBusInterface" instance in the "Symfony\Component\Messenger\Tests\TestQueryBus::$messageBus" property, but that property | Symfony\Component\Messenger\Stamp\StampInterface;
use Symfony\Component\Messenger\Tests\Fixtures\DummyMessage;
class HandleTraitTest extends TestCase
{
public function testItThrowsOnNoMessageBusInstance()
{
$this | {
"filepath": "src/Symfony/Component/Messenger/Tests/HandleTraitTest.php",
"language": "php",
"file_size": 4463,
"cut_index": 614,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Messenger\Tests;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\MessageBus;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\... |
public function testItHasTheRightInterface()
{
$bus = new MessageBus();
$this->assertInstanceOf(MessageBusInterface::class, $bus);
}
public function testItCallsMiddleware()
{
$message = new DummyMessage('Hello | elayStamp;
use Symfony\Component\Messenger\Stamp\ReceivedStamp;
use Symfony\Component\Messenger\Tests\Fixtures\AnEnvelopeStamp;
use Symfony\Component\Messenger\Tests\Fixtures\DummyMessage;
class MessageBusTest extends TestCase
{ | {
"filepath": "src/Symfony/Component/Messenger/Tests/MessageBusTest.php",
"language": "php",
"file_size": 6215,
"cut_index": 716,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Container;
us... | $envelope = new Envelope(new \stdClass(), [new BusNameStamp('foo_bus')]);
$bus1 = $this->createMock(MessageBusInterface::class);
$bus2 = $this->createMock(MessageBusInterface::class);
$container = new Container();
$ | \RoutableMessageBus;
use Symfony\Component\Messenger\Stamp\BusNameStamp;
use Symfony\Component\Messenger\Stamp\DelayStamp;
class RoutableMessageBusTest extends TestCase
{
public function testItRoutesToTheCorrectBus()
{
| {
"filepath": "src/Symfony/Component/Messenger/Tests/RoutableMessageBusTest.php",
"language": "php",
"file_size": 2812,
"cut_index": 563,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Messenger\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Messenger\Stamp\DelayStamp;
use Symfony\Component\Messenger\Stamp\HandledStamp;
use Symfony... | amp(5);
$bus = $this->createMock(MessageBusInterface::class);
$bus->expects($this->once())->method('dispatch')->with($message, [$stamp])->willReturn(new Envelope($message, [$stamp]));
$traceableBus = new TraceableMessageBus($bus);
| ;
use Symfony\Component\Messenger\TraceableMessageBus;
class TraceableMessageBusTest extends TestCase
{
public function testItTracesDispatch()
{
$message = new DummyMessage('Hello');
$stamp = new DelaySt | {
"filepath": "src/Symfony/Component/Messenger/Tests/TraceableMessageBusTest.php",
"language": "php",
"file_size": 6965,
"cut_index": 716,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messeng... | $data = [
'queueNames' => ['c', 'b', 'a'],
'transportNames' => ['a', 'b', 'c'],
];
$metadata = new WorkerMetadata($data);
$this->assertSame($data['queueNames'], $metadata->getQueueNames());
$this-> | $metadata = new WorkerMetadata([]);
$this->assertNull($metadata->getQueueNames());
$this->assertSame([], $metadata->getTransportNames());
}
public function testItReturnsProvidedMetadata()
{
| {
"filepath": "src/Symfony/Component/Messenger/Tests/WorkerMetadataTest.php",
"language": "php",
"file_size": 1523,
"cut_index": 537,
"middle_length": 229
} |
nent\Messenger\Handler\BatchHandlerTrait;
use Symfony\Component\Messenger\Handler\HandlerDescriptor;
use Symfony\Component\Messenger\Handler\HandlersLocator;
use Symfony\Component\Messenger\MessageBus;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Messenger\Middleware\HandleMessageMiddlewar... | essenger\Tests\Fixtures\DummyMessageInterface;
use Symfony\Component\Messenger\Tests\Fixtures\DummyReceiver;
use Symfony\Component\Messenger\Tests\Fixtures\ResettableDummyReceiver;
use Symfony\Component\Messenger\Transport\Receiver\KeepaliveReceiverInterfa | \Component\Messenger\Stamp\ReceivedStamp;
use Symfony\Component\Messenger\Stamp\SentStamp;
use Symfony\Component\Messenger\Stamp\StampInterface;
use Symfony\Component\Messenger\Tests\Fixtures\DummyMessage;
use Symfony\Component\M | {
"filepath": "src/Symfony/Component/Messenger/Tests/WorkerTest.php",
"language": "php",
"file_size": 41871,
"cut_index": 2151,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\Exception;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Exception\DelayedMessa... | extends \RuntimeException {
public function __construct()
{
$this->code = 'HY000';
$this->message = 'test';
// no to call parent constructor, it will fail with string error code
| \Fixtures\MyOwnException;
class HandlerFailedExceptionTest extends TestCase
{
public function testThatStringErrorCodeConvertsToInteger()
{
$envelope = new Envelope(new \stdClass());
$exception = new class | {
"filepath": "src/Symfony/Component/Messenger/Tests/Exception/HandlerFailedExceptionTest.php",
"language": "php",
"file_size": 4592,
"cut_index": 614,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Messenger\Tests\DataCollector;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\DataCollector\MessengerDataCollector;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Messeng... | $this->dumper->setColors(false);
}
public function testHandle()
{
$message = new DummyMessage('dummy message');
$envelope = new Envelope($message);
$bus = $this->createMock(MessageBusInterface::class);
$ | hor Maxime Steinhausser <maxime.steinhausser@gmail.com>
*/
class MessengerDataCollectorTest extends TestCase
{
private CliDumper $dumper;
protected function setUp(): void
{
$this->dumper = new CliDumper();
| {
"filepath": "src/Symfony/Component/Messenger/Tests/DataCollector/MessengerDataCollectorTest.php",
"language": "php",
"file_size": 5877,
"cut_index": 716,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\Fixtures;
use Symfony\Component\Messenger\Envelope;
use Symfon... | ivate array $deliveriesOfEnvelopes,
) {
}
/**
* @param int $fetchSize
*/
public function get(/* int $fetchSize = 1 */): iterable
{
$this->fetchSizes[] = \func_num_args() > 0 ? func_get_arg(0) : 1;
$val = arra | pes = [];
private int $acknowledgeCount = 0;
private int $rejectCount = 0;
private array $fetchSizes = [];
/**
* @param Envelope[][] $deliveriesOfEnvelopes
*/
public function __construct(
pr | {
"filepath": "src/Symfony/Component/Messenger/Tests/Fixtures/DummyReceiver.php",
"language": "php",
"file_size": 1887,
"cut_index": 537,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\Transport;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Exception\Invalid... | testThrowsExceptionOnUnsupportedTransport(array $transportSupport, string $dsn, ?string $expectedMessage)
{
if (null !== $expectedMessage) {
$this->expectException(InvalidArgumentException::class);
$this->expectExceptio | sport\TransportFactoryInterface;
use Symfony\Component\Messenger\Transport\TransportInterface;
class TransportFactoryTest extends TestCase
{
#[DataProvider('provideThrowsExceptionOnUnsupportedTransport')]
public function | {
"filepath": "src/Symfony/Component/Messenger/Tests/Transport/TransportFactoryTest.php",
"language": "php",
"file_size": 4027,
"cut_index": 614,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Messenger\Tests\Transport\Sender;
use PHPUnit\Framework\Attributes\TestWith;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\Messenger\Envelope;
use Symfony\Com... | se Symfony\Component\Messenger\Tests\Fixtures\SecondMessage;
use Symfony\Component\Messenger\Transport\Sender\SenderInterface;
use Symfony\Component\Messenger\Transport\Sender\SendersLocator;
class SendersLocatorTest extends TestCase
{
public function | nent\Messenger\Tests\Fixtures\DummyMessageWithAttribute;
use Symfony\Component\Messenger\Tests\Fixtures\DummyMessageWithInterfaceWithAttribute;
use Symfony\Component\Messenger\Tests\Fixtures\DummyMessageWithParentWithAttribute;
u | {
"filepath": "src/Symfony/Component/Messenger/Tests/Transport/Sender/SendersLocatorTest.php",
"language": "php",
"file_size": 6756,
"cut_index": 716,
"middle_length": 229
} |
n Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\Transport\Sync;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\MessageBus;
use Symfony\Com... | public function testCreateTransport()
{
$serializer = $this->createStub(SerializerInterface::class);
$factory = new SyncTransportFactory(new MessageBus());
$transport = $factory->createTransport('sync://', [], $serializer);
|
class SyncTransportFactoryTest extends TestCase
{
| {
"filepath": "src/Symfony/Component/Messenger/Tests/Transport/Sync/SyncTransportFactoryTest.php",
"language": "php",
"file_size": 965,
"cut_index": 582,
"middle_length": 52
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\Transport\Sync;
use PHPUnit\Framework\TestCase;
u... |
->with($this->callback(function ($arg) {
$this->assertInstanceOf(Envelope::class, $arg);
return true;
}))
->willReturnArgument(0);
$message = new \stdClass();
$envelope = | c\SyncTransport;
class SyncTransportTest extends TestCase
{
public function testSend()
{
$bus = $this->createMock(MessageBusInterface::class);
$bus->expects($this->once())
->method('dispatch') | {
"filepath": "src/Symfony/Component/Messenger/Tests/Transport/Sync/SyncTransportTest.php",
"language": "php",
"file_size": 1269,
"cut_index": 524,
"middle_length": 229
} |
Messenger\Envelope;
use Symfony\Component\Messenger\Exception\MessageDecodingFailedException;
use Symfony\Component\Messenger\Stamp\NonSendableStampInterface;
use Symfony\Component\Messenger\Tests\Fixtures\DummyLegacySerializable;
use Symfony\Component\Messenger\Tests\Fixtures\DummyMessage;
use Symfony\Component\Messen... | se (&$errorHandler) {
if (\E_DEPRECATED === $errno && str_contains($errstr, 'Serializable interface')) {
return true;
}
return $errorHandler ? $errorHandler(...\func_get_args()) : false;
});
try {
class_exists(DummyLegacySerializa | // Force-load the deprecated-Serializable fixture under an error handler that swallows
// the PHP deprecation it triggers at class-declaration time.
$errorHandler = set_error_handler(static function (int $errno, string $errstr) u | {
"filepath": "src/Symfony/Component/Messenger/Tests/Transport/Serialization/PhpSerializerTest.php",
"language": "php",
"file_size": 11938,
"cut_index": 921,
"middle_length": 229
} |
nent\Clock\ClockInterface;
use Symfony\Component\Messenger\Event\WorkerMessageFailedEvent;
use Symfony\Component\Messenger\Event\WorkerMessageHandledEvent;
use Symfony\Component\Messenger\Event\WorkerMessageReceivedEvent;
use Symfony\Component\Messenger\Event\WorkerRateLimitedEvent;
use Symfony\Component\Messenger\Even... | e Symfony\Component\Messenger\Execution\MessageExecutionStrategyInterface;
use Symfony\Component\Messenger\Execution\SyncMessageExecutionStrategy;
use Symfony\Component\Messenger\Stamp\AckStamp;
use Symfony\Component\Messenger\Stamp\ConsumedByWorkerStamp;
| eExceptionInterface;
use Symfony\Component\Messenger\Exception\RejectRedeliveredMessageException;
use Symfony\Component\Messenger\Exception\RuntimeException;
use Symfony\Component\Messenger\Execution\DeferredBatchMessageQueue;
us | {
"filepath": "src/Symfony/Component/Messenger/Worker.php",
"language": "php",
"file_size": 14244,
"cut_index": 921,
"middle_length": 229
} |
n Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Exception;
use Symfony\Component\Messenger\Envelope;
/**
* Thrown when a message cannot be decoded in a seriali... | nvelope = [],
) {
parent::__construct($message, $code, $previous);
}
public static function wrap(array $encodedEnvelope, string $message, int $code = 0, ?\Throwable $previous = null): Envelope
{
return new Envelope(new self | ious = null,
public readonly array $encodedE | {
"filepath": "src/Symfony/Component/Messenger/Exception/MessageDecodingFailedException.php",
"language": "php",
"file_size": 947,
"cut_index": 582,
"middle_length": 52
} |
?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Exception;
/**
* Exception that holds multi... | m class-string<TException>|null $class
*
* @return \Throwable[]
*
* @psalm-return ($class is null ? \Throwable[] : TException[])
*/
public function getWrappedExceptions(?string $class = null, bool $recursive = false): array;
}
| emplate TException of \Throwable
*
* @para | {
"filepath": "src/Symfony/Component/Messenger/Exception/WrappedExceptionsInterface.php",
"language": "php",
"file_size": 821,
"cut_index": 513,
"middle_length": 52
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Transport;
use Symfony\Component\Messenger\Exception\InvalidArgumentException;
use Symfony\Component\Messenger\Transport\Serialization\Serializer... | string $dsn, array $options, SerializerInterface $serializer): TransportInterface
{
foreach ($this->factories as $factory) {
if ($factory->supports($dsn, $options)) {
return $factory->createTransport($dsn, $options, |
/**
* @param iterable<mixed, TransportFactoryInterface> $factories
*/
public function __construct(
private iterable $factories,
) {
}
public function createTransport(#[\SensitiveParameter] | {
"filepath": "src/Symfony/Component/Messenger/Transport/TransportFactory.php",
"language": "php",
"file_size": 3886,
"cut_index": 614,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Middleware;
use Psr\Container\ContainerInterface;
use Symfony\Component\Messenger\Envelope;
us... | @author Nicolas Grekas <p@tchwork.com>
*/
final class DecodeFailedMessageMiddleware implements MiddlewareInterface
{
public function __construct(
private ContainerInterface $serializerLocator,
) {
}
public function handle(Envelope | ny\Component\Messenger\Stamp\SentToFailureTransportStamp;
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
/**
* Replays the transport serializer when a message could not be decoded initially.
*
* | {
"filepath": "src/Symfony/Component/Messenger/Middleware/DecodeFailedMessageMiddleware.php",
"language": "php",
"file_size": 2638,
"cut_index": 563,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Middleware;
use Symfony\Component\Lock\LockFactory;
use Symfony\Comp... | p::class)) {
return $stack->next()->handle($envelope, $stack);
}
if (!$envelope->last(ReceivedStamp::class)) {
$lock = $this->lockFactory->createLockFromKey($stamp->getKey(), $stamp->getTtl(), false);
i | nterface
{
public function __construct(private LockFactory $lockFactory)
{
}
public function handle(Envelope $envelope, StackInterface $stack): Envelope
{
if (!$stamp = $envelope->last(DeduplicateStam | {
"filepath": "src/Symfony/Component/Messenger/Middleware/DeduplicateMiddleware.php",
"language": "php",
"file_size": 1518,
"cut_index": 537,
"middle_length": 229
} |
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Middleware;
use Symfony\Component\Messenger\Envel... | Stamp
if ($envelope->last(ReceivedStamp::class) && $sentToFailureStamp = $envelope->last(SentToFailureTransportStamp::class)) {
// mark the message as "received" from the original transport
// this guarantees the same behavi | dMessageProcessingMiddleware implements MiddlewareInterface
{
public function handle(Envelope $envelope, StackInterface $stack): Envelope
{
// look for "received" messages decorated with the SentToFailureTransport | {
"filepath": "src/Symfony/Component/Messenger/Middleware/FailedMessageProcessingMiddleware.php",
"language": "php",
"file_size": 1219,
"cut_index": 518,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Middleware;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Stamp\Co... |
public function handle(Envelope $envelope, StackInterface $stack): Envelope
{
$context = $this->router->getContext();
if (!$envelope->last(ConsumedByWorkerStamp::class) || !$contextStamp = $envelope->last(RouterContextStamp::class | e message.
*
* @author Jérémy Derussé <jeremy@derusse.com>
*/
class RouterContextMiddleware implements MiddlewareInterface
{
public function __construct(
private RequestContextAwareInterface $router,
) {
}
| {
"filepath": "src/Symfony/Component/Messenger/Middleware/RouterContextMiddleware.php",
"language": "php",
"file_size": 2928,
"cut_index": 563,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Middleware;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Log\LoggerAwareTrait;
use Symfony\Component\Messenger\Envelope;
use Symfony... | torInterface;
/**
* @author Samuel Roze <samuel.roze@gmail.com>
* @author Tobias Schultze <http://tobion.de>
*/
class SendMessageMiddleware implements MiddlewareInterface
{
use LoggerAwareTrait;
public function __construct(
private Sen | on;
use Symfony\Component\Messenger\Stamp\FlushBatchHandlersStamp;
use Symfony\Component\Messenger\Stamp\ReceivedStamp;
use Symfony\Component\Messenger\Stamp\SentStamp;
use Symfony\Component\Messenger\Transport\Sender\SendersLoca | {
"filepath": "src/Symfony/Component/Messenger/Middleware/SendMessageMiddleware.php",
"language": "php",
"file_size": 3124,
"cut_index": 614,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Middleware;
use Symfony\Component\Messenger\Envelope;
/**
* @author Nicolas Grekas <p@tchwor... | ll === $middlewareIterator) {
return;
}
if ($middlewareIterator instanceof \Iterator) {
$this->stack->iterator = $middlewareIterator;
} elseif ($middlewareIterator instanceof MiddlewareInterface) {
| wareInterface>|MiddlewareInterface|null $middlewareIterator
*/
public function __construct(iterable|MiddlewareInterface|null $middlewareIterator = null)
{
$this->stack = new MiddlewareStack();
if (nu | {
"filepath": "src/Symfony/Component/Messenger/Middleware/StackMiddleware.php",
"language": "php",
"file_size": 2225,
"cut_index": 563,
"middle_length": 229
} |
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Middleware;
use Symfony\Component\Messenger\Envel... | tion handle(Envelope $envelope, StackInterface $stack): Envelope
{
$message = $envelope->getMessage();
$groups = $envelope->last(ValidationStamp::class)?->getGroups();
$violations = $this->validator->validate($message, null, $g | /**
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
class ValidationMiddleware implements MiddlewareInterface
{
public function __construct(
private ValidatorInterface $validator,
) {
}
public func | {
"filepath": "src/Symfony/Component/Messenger/Middleware/ValidationMiddleware.php",
"language": "php",
"file_size": 1206,
"cut_index": 518,
"middle_length": 229
} |
ent\Console\Completion\CompletionSuggestions;
use Symfony\Component\Console\Helper\Dumper;
use Symfony\Component\Console\Question\ChoiceQuestion;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\ErrorHandler\Exception\FlattenException;
use Symfony\Component\Messenger\Envelope;
use Symfony\Compone... | eIdStamp;
use Symfony\Component\Messenger\Transport\Receiver\ListableReceiverInterface;
use Symfony\Component\Messenger\Transport\Receiver\MessageCountAwareInterface;
use Symfony\Component\Messenger\Transport\Receiver\ReceiverInterface;
use Symfony\Compone | Component\Messenger\Stamp\MessageDecodingFailedStamp;
use Symfony\Component\Messenger\Stamp\RedeliveryStamp;
use Symfony\Component\Messenger\Stamp\SentToFailureTransportStamp;
use Symfony\Component\Messenger\Stamp\TransportMessag | {
"filepath": "src/Symfony/Component/Messenger/Command/AbstractFailedMessagesCommand.php",
"language": "php",
"file_size": 9506,
"cut_index": 921,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Command;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Completi... | Roland Franssen <franssen.roland@gmail.com>
*/
#[AsCommand(name: 'debug:messenger', description: 'List messages you can dispatch using the message buses')]
class DebugCommand extends Command
{
public function __construct(
private array $mappin |
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
/**
* A console command to debug Messenger information.
*
* @author | {
"filepath": "src/Symfony/Component/Messenger/Command/DebugCommand.php",
"language": "php",
"file_size": 4597,
"cut_index": 614,
"middle_length": 229
} |
lableCommandInterface;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Sty... | Component\Messenger\Transport\Receiver\ListableReceiverInterface;
use Symfony\Component\Messenger\Transport\Receiver\ReceiverInterface;
use Symfony\Component\Messenger\Transport\Receiver\SingleMessageReceiver;
use Symfony\Component\Messenger\Transport\Seri | essageSkipEvent;
use Symfony\Component\Messenger\EventListener\StopWorkerOnMessageLimitListener;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Messenger\Stamp\SentToFailureTransportStamp;
use Symfony\ | {
"filepath": "src/Symfony/Component/Messenger/Command/FailedMessagesRetryCommand.php",
"language": "php",
"file_size": 12043,
"cut_index": 921,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Command;
use Psr\Container\ContainerInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
... | nt Touzet <vincent.touzet@gmail.com>
*/
#[AsCommand(name: 'messenger:setup-transports', description: 'Prepare the required infrastructure for the transport')]
class SetupTransportsCommand extends Command
{
public function __construct(
private | nt\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Messenger\Transport\SetupableTransportInterface;
/**
* @author Vince | {
"filepath": "src/Symfony/Component/Messenger/Command/SetupTransportsCommand.php",
"language": "php",
"file_size": 3253,
"cut_index": 614,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger;
use Psr\Container\ContainerInterface;
use Symfony\Component\Messenger\Exception\InvalidArgume... | $busLocator,
private ?MessageBusInterface $fallbackBus = null,
) {
}
public function dispatch(object $envelope, array $stamps = []): Envelope
{
if (!$envelope instanceof Envelope) {
throw new InvalidArgumentExce | om the transport can be sent to the correct bus.
*
* @author Ryan Weaver <ryan@symfonycasts.com>
*/
class RoutableMessageBus implements MessageBusInterface
{
public function __construct(
private ContainerInterface | {
"filepath": "src/Symfony/Component/Messenger/RoutableMessageBus.php",
"language": "php",
"file_size": 2030,
"cut_index": 563,
"middle_length": 229
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Exception;
use Symfony\Component\Messenger\Envelope;
/... | dExceptionsTrait;
public function __construct(
private array $exceptions,
?Envelope $envelope = null,
) {
$this->envelope = $envelope;
$exceptionMessages = implode(", \n", array_map(
static fn (\Throwab | bias Nyholm <tobias.nyholm@gmail.com>
*/
class DelayedMessageHandlingException extends RuntimeException implements WrappedExceptionsInterface, EnvelopeAwareExceptionInterface
{
use EnvelopeAwareExceptionTrait;
use Wrappe | {
"filepath": "src/Symfony/Component/Messenger/Exception/DelayedMessageHandlingException.php",
"language": "php",
"file_size": 1473,
"cut_index": 524,
"middle_length": 229
} |
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Transport\Sender;
use Symfony\Component\Messenger\Enve... | for transport configuration,
* like delivery delay.
*
* If applicable, the returned Envelope should contain a TransportMessageIdStamp.
*
* @throws ExceptionInterface
*/
public function send(Envelope $envelope): Envelope;
} |
*
* The sender can read different stamps | {
"filepath": "src/Symfony/Component/Messenger/Transport/Sender/SenderInterface.php",
"language": "php",
"file_size": 832,
"cut_index": 523,
"middle_length": 52
} |
buted with this source code.
*/
namespace Symfony\Component\Messenger\Middleware;
use Psr\Clock\ClockInterface;
use Psr\Log\LoggerAwareTrait;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Exception\HandlerFailedException;
use Symfony\Component\Messenger\Exception\LogicException;
use Symfo... | onent\Messenger\Stamp\HandlerArgumentsStamp;
use Symfony\Component\Messenger\Stamp\NoAutoAckStamp;
/**
* @author Samuel Roze <samuel.roze@gmail.com>
*/
class HandleMessageMiddleware implements MiddlewareInterface
{
use LoggerAwareTrait;
public | onent\Messenger\Handler\HandlersLocatorInterface;
use Symfony\Component\Messenger\Stamp\AckStamp;
use Symfony\Component\Messenger\Stamp\FlushBatchHandlersStamp;
use Symfony\Component\Messenger\Stamp\HandledStamp;
use Symfony\Comp | {
"filepath": "src/Symfony/Component/Messenger/Middleware/HandleMessageMiddleware.php",
"language": "php",
"file_size": 6155,
"cut_index": 716,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Middleware;
use Symfony\Component\Messenger\Bridge\Amqp\Transport\Am... | t by the worker and will trigger the retry logic according to the retry strategy.
*
* AMQP redelivers messages when they do not get acknowledged or rejected. This can happen when the connection times out
* or an exception is thrown before acknowledging | eException when a message is detected that has been redelivered by AMQP.
*
* The middleware runs before the HandleMessageMiddleware and prevents redelivered messages from being handled directly.
* The thrown exception is caugh | {
"filepath": "src/Symfony/Component/Messenger/Middleware/RejectRedeliveredMessageMiddleware.php",
"language": "php",
"file_size": 1887,
"cut_index": 537,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Config\Tests\Definition\Dumper;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Dumper\XmlReferenceDumper;
use Symfony\Component\Co... | ExampleConfiguration();
$dumper = new XmlReferenceDumper();
$this->assertEquals(str_replace('http://example.org/schema/dic/acme_root', 'http://symfony.com/schema/dic/symfony', $this->getConfigurationAsString()), $dumper->dump($configuratio | n();
$dumper = new XmlReferenceDumper();
$this->assertEquals($this->getConfigurationAsString(), $dumper->dump($configuration));
}
public function testNamespaceDumper()
{
$configuration = new | {
"filepath": "src/Symfony/Component/Config/Tests/Definition/Dumper/XmlReferenceDumperTest.php",
"language": "php",
"file_size": 4488,
"cut_index": 614,
"middle_length": 229
} |
fony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ChoiceQuestion;
use Symfony\Component\Console\SignalRegistry\SignalRegistry;
use Symfony\Component\Console\Style\SymfonyStyle;
use Sy... | Symfony\Component\Messenger\Transport\Sync\SyncTransport;
use Symfony\Component\Messenger\Worker;
/**
* @author Samuel Roze <samuel.roze@gmail.com>
*/
#[AsCommand(name: 'messenger:consume', description: 'Consume messages')]
class ConsumeMessagesCommand | LimitListener;
use Symfony\Component\Messenger\EventListener\StopWorkerOnMemoryLimitListener;
use Symfony\Component\Messenger\EventListener\StopWorkerOnMessageLimitListener;
use Symfony\Component\Messenger\RoutableMessageBus;
use | {
"filepath": "src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php",
"language": "php",
"file_size": 18098,
"cut_index": 1331,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Messenger\Command;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Cons... | iption: 'Show one or more messages from the failure transport')]
class FailedMessagesShowCommand extends AbstractFailedMessagesCommand
{
protected function configure(): void
{
$this
->setDefinition([
new InputArg | ony\Component\Messenger\Stamp\RedeliveryStamp;
use Symfony\Component\Messenger\Transport\Receiver\ListableReceiverInterface;
/**
* @author Ryan Weaver <ryan@symfonycasts.com>
*/
#[AsCommand(name: 'messenger:failed:show', descr | {
"filepath": "src/Symfony/Component/Messenger/Command/FailedMessagesShowCommand.php",
"language": "php",
"file_size": 7482,
"cut_index": 716,
"middle_length": 229
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Exception;
/**
* A concrete implementation of Recovera... | ort, which can cause unbounded retries. Pass
* false to let the configured retry strategy bound the number of attempts.
*/
public function __construct(
string $message = '',
int $code = 0,
?\Thr | rableExceptionInterface
{
/**
* @param bool $forceRetry When true (the default, preserving 8.0 semantics), the message will be retried regardless
* of the configured max_retries on the transp | {
"filepath": "src/Symfony/Component/Messenger/Exception/RecoverableMessageHandlingException.php",
"language": "php",
"file_size": 1382,
"cut_index": 524,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Middleware;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Exception\DelayedMessageHandlingException;
use Symfony\Comp... | sages with a DispatchAfterCurrentBus stamp would be
* handled after the Doctrine transaction has been committed.
*
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
class DispatchAfterCurrentBusMiddleware implements MiddlewareInterface
{
/**
| spatchAfterCurrentBus stamp
* will actually be handled once the current message being dispatched is fully
* handled.
*
* For instance, using this middleware before the DoctrineTransactionMiddleware
* means sub-dispatched mes | {
"filepath": "src/Symfony/Component/Messenger/Middleware/DispatchAfterCurrentBusMiddleware.php",
"language": "php",
"file_size": 4461,
"cut_index": 614,
"middle_length": 229
} |
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Transport\Sync;
use Symfony\Component\Messenger\M... | unction __construct(
private MessageBusInterface $messageBus,
) {
}
public function createTransport(#[\SensitiveParameter] string $dsn, array $options, SerializerInterface $serializer): TransportInterface
{
return new SyncT | enger\Transport\TransportInterface;
/**
* @author Ryan Weaver <ryan@symfonycasts.com>
*
* @implements TransportFactoryInterface<SyncTransport>
*/
class SyncTransportFactory implements TransportFactoryInterface
{
public f | {
"filepath": "src/Symfony/Component/Messenger/Transport/Sync/SyncTransportFactory.php",
"language": "php",
"file_size": 1189,
"cut_index": 518,
"middle_length": 229
} |
?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Message;
use Symfony\Component\Messenger\Env... | public function __toString(): string
{
$message = $this->envelope instanceof Envelope ? $this->envelope->getMessage() : $this->envelope;
return \sprintf('%s via %s', $message instanceof \Stringable ? (string) $message : $message::class | ]|string $transportNames Transport names to be used for the message
*/
public function __construct(
public readonly object $envelope,
public readonly array|string $transportNames = [],
) {
}
| {
"filepath": "src/Symfony/Component/Messenger/Message/RedispatchMessage.php",
"language": "php",
"file_size": 1055,
"cut_index": 513,
"middle_length": 229
} |
*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Attribute;
/**
* Attribute for configuring message... | the message should be routed.
*/
public string|array|null $transport = null,
/**
* The serialized type to use when sending or receiving the message.
*/
public ?string $serializedTypeName = null,
) {
| /**
* Name of the transports to which | {
"filepath": "src/Symfony/Component/Messenger/Attribute/AsMessage.php",
"language": "php",
"file_size": 835,
"cut_index": 520,
"middle_length": 52
} |
buted with this source code.
*/
namespace Symfony\Component\Messenger\Command;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Cons... | from the failure transport')]
class FailedMessagesRemoveCommand extends AbstractFailedMessagesCommand
{
protected function configure(): void
{
$this
->setDefinition([
new InputArgument('id', InputArgument::OPTION | erInterface;
use Symfony\Component\Messenger\Transport\Receiver\MessageCountAwareInterface;
/**
* @author Ryan Weaver <ryan@symfonycasts.com>
*/
#[AsCommand(name: 'messenger:failed:remove', description: 'Remove given messages | {
"filepath": "src/Symfony/Component/Messenger/Command/FailedMessagesRemoveCommand.php",
"language": "php",
"file_size": 7333,
"cut_index": 716,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Middleware;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Stopwatch\Stopwatc... | ce $stack): Envelope
{
$stack = new TraceableStack($stack, $this->stopwatch, $this->busName, $this->eventCategory);
try {
return $stack->next()->handle($envelope, $stack);
} finally {
$stack->stop();
| nction __construct(
private Stopwatch $stopwatch,
private string $busName,
private string $eventCategory = 'messenger.middleware',
) {
}
public function handle(Envelope $envelope, StackInterfa | {
"filepath": "src/Symfony/Component/Messenger/Middleware/TraceableMiddleware.php",
"language": "php",
"file_size": 2335,
"cut_index": 563,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\Transport\InMemory;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Envelope... | ansportFactoryTest extends TestCase
{
private InMemoryTransportFactory $factory;
protected function setUp(): void
{
$this->factory = new InMemoryTransportFactory();
}
#[DataProvider('provideDSN')]
public function testSuppo | rt;
use Symfony\Component\Messenger\Transport\InMemory\InMemoryTransportFactory;
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
/**
* @author Gary PEGEOT <garypegeot@gmail.com>
*/
class InMemoryTr | {
"filepath": "src/Symfony/Component/Messenger/Tests/Transport/InMemory/InMemoryTransportFactoryTest.php",
"language": "php",
"file_size": 3473,
"cut_index": 614,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Messenger\Tests\Command;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\DependencyInjection\ServiceLocator;
use Symfony\Component\Messenger\Command\StatsCommand;
use Symfony\Component\Messenger\Tran... | getMessageCount')->willReturn(6);
$simpleTransport = $this->createStub(TransportInterface::class);
// mock a service locator
$serviceLocator = $this->createStub(ServiceLocator::class);
$serviceLocator
->method( | nds TestCase
{
private StatsCommand $command;
protected function setUp(): void
{
$messageCountableTransport = $this->createStub(MessageCountAwareInterface::class);
$messageCountableTransport->method(' | {
"filepath": "src/Symfony/Component/Messenger/Tests/Command/StatsCommandTest.php",
"language": "php",
"file_size": 7742,
"cut_index": 716,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\Command;
use PHPUnit\Framework\TestCase;
use Psr\Cache\CacheIt... | ects($this->once())->method('set');
$cachePool->expects($this->once())->method('getItem')->willReturn($cacheItem);
$cachePool->expects($this->once())->method('save')->with($cacheItem);
$command = new StopWorkersCommand($cachePool); | extends TestCase
{
public function testItSetsCacheItem()
{
$cachePool = $this->createMock(CacheItemPoolInterface::class);
$cacheItem = $this->createMock(CacheItemInterface::class);
$cacheItem->exp | {
"filepath": "src/Symfony/Component/Messenger/Tests/Command/StopWorkersCommandTest.php",
"language": "php",
"file_size": 1871,
"cut_index": 537,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\EventListener;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Envelope;... | ss());
$exception = new \Exception('It failed!');
$event = new WorkerMessageFailedEvent($envelope, 'my_receiver', $exception);
$expectedStamp = ErrorDetailsStamp::create($exception);
$listener->onMessageFailed($event);
| tamp;
final class AddErrorDetailsStampListenerTest extends TestCase
{
public function testExceptionDetailsAreAdded()
{
$listener = new AddErrorDetailsStampListener();
$envelope = new Envelope(new \stdCla | {
"filepath": "src/Symfony/Component/Messenger/Tests/EventListener/AddErrorDetailsStampListenerTest.php",
"language": "php",
"file_size": 2339,
"cut_index": 563,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\EventListener;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Lock\LockFactory;
use Symfony\Component\Lock\SharedLockInterface;
use ... | tion testLockIsReleasedWhenMessageWillNotRetry()
{
$lock = $this->createMock(SharedLockInterface::class);
$lock->expects($this->once())->method('release');
$lockFactory = $this->createMock(LockFactory::class);
$lockFact | se Symfony\Component\Messenger\EventListener\SendFailedMessageForRetryListener;
use Symfony\Component\Messenger\Stamp\DeduplicateStamp;
final class ReleaseDeduplicationLockOnFailureListenerTest extends TestCase
{
public func | {
"filepath": "src/Symfony/Component/Messenger/Tests/EventListener/ReleaseDeduplicationLockOnFailureListenerTest.php",
"language": "php",
"file_size": 3421,
"cut_index": 614,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\EventListener;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Test... | TestCase
{
public static function provideResetServices(): iterable
{
yield [true];
yield [false];
}
#[DataProvider('provideResetServices')]
public function testResetServices(bool $shouldReset)
{
$resettable | y\Component\Messenger\EventListener\ResetServicesListener;
use Symfony\Component\Messenger\MessageBus;
use Symfony\Component\Messenger\Worker;
use Symfony\Contracts\Service\ResetInterface;
class ResetServicesListenerTest extends | {
"filepath": "src/Symfony/Component/Messenger/Tests/EventListener/ResetServicesListenerTest.php",
"language": "php",
"file_size": 2061,
"cut_index": 563,
"middle_length": 229
} |
\Messenger\Exception\RecoverableMessageHandlingException;
use Symfony\Component\Messenger\Retry\MultiplierRetryStrategy;
use Symfony\Component\Messenger\Retry\RetryStrategyInterface;
use Symfony\Component\Messenger\Stamp\DelayStamp;
use Symfony\Component\Messenger\Stamp\RedeliveryStamp;
use Symfony\Component\Messenger\... | = new Container();
$sendersLocator->set('my_receiver', $sender);
$listener = new SendFailedMessageForRetryListener($sendersLocator, new Container());
$exception = new \Exception('no!');
$envelope = new Envelope(new \stdCla | erTest extends TestCase
{
public function testNoRetryStrategyCausesNoRetry()
{
$sender = $this->createMock(SenderInterface::class);
$sender->expects($this->never())->method('send');
$sendersLocator | {
"filepath": "src/Symfony/Component/Messenger/Tests/EventListener/SendFailedMessageForRetryListenerTest.php",
"language": "php",
"file_size": 20749,
"cut_index": 1331,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Messenger\Tests\EventListener;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ServiceLocator;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Event\WorkerMessageFailedEvent;
use Symfony\Component\Messenge... | SenderInterface::class);
$sender->expects($this->once())->method('send')->with($this->callback(function ($envelope) use ($receiverName) {
$this->assertInstanceOf(Envelope::class, $envelope);
$sentToFailureTransportStamp = $e | ;
class SendFailedMessageToFailureTransportListenerTest extends TestCase
{
public function testItSendsToTheFailureTransportWithSenderLocator()
{
$receiverName = 'my_receiver';
$sender = $this->createMock( | {
"filepath": "src/Symfony/Component/Messenger/Tests/EventListener/SendFailedMessageToFailureTransportListenerTest.php",
"language": "php",
"file_size": 7901,
"cut_index": 716,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\EventListener;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Test... | eption\StopWorkerExceptionInterface;
use Symfony\Component\Messenger\Worker;
class StopWorkerOnCustomStopExceptionListenerTest extends TestCase
{
public static function provideTests(): \Generator
{
yield 'it should not stop (1)' => [new \E | Messenger\EventListener\StopWorkerOnCustomStopExceptionListener;
use Symfony\Component\Messenger\Exception\HandlerFailedException;
use Symfony\Component\Messenger\Exception\StopWorkerException;
use Symfony\Component\Messenger\Exc | {
"filepath": "src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnCustomStopExceptionListenerTest.php",
"language": "php",
"file_size": 2726,
"cut_index": 563,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\EventListener;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Test... | r;
class StopWorkerOnFailureLimitListenerTest extends TestCase
{
#[DataProvider('countProvider')]
public function testWorkerStopsWhenMaximumCountReached(int $max, bool $shouldStop)
{
$worker = $this->createMock(Worker::class);
| Event;
use Symfony\Component\Messenger\EventListener\StopWorkerOnFailureLimitListener;
use Symfony\Component\Messenger\MessageBus;
use Symfony\Component\Messenger\Tests\Fixtures\DummyMessage;
use Symfony\Component\Messenger\Worke | {
"filepath": "src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnFailureLimitListenerTest.php",
"language": "php",
"file_size": 2787,
"cut_index": 563,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\EventListener;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Test... | emoryUsage, int $memoryLimit, bool $shouldStop)
{
$memoryResolver = static fn () => $memoryUsage;
$worker = $this->createMock(Worker::class);
$worker->expects($shouldStop ? $this->once() : $this->never())->method('stop');
| t\Messenger\MessageBus;
use Symfony\Component\Messenger\Worker;
class StopWorkerOnMemoryLimitListenerTest extends TestCase
{
#[DataProvider('memoryProvider')]
public function testWorkerStopsWhenMemoryLimitExceeded(int $m | {
"filepath": "src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnMemoryLimitListenerTest.php",
"language": "php",
"file_size": 2061,
"cut_index": 563,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\EventListener;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Test... | $max, bool $shouldStop)
{
$worker = $this->createMock(Worker::class);
$worker->expects($shouldStop ? $this->atLeastOnce() : $this->never())->method('stop');
$event = new WorkerRunningEvent($worker, false);
$maximumCount | nt\Messenger\MessageBus;
use Symfony\Component\Messenger\Worker;
class StopWorkerOnMessageLimitListenerTest extends TestCase
{
#[DataProvider('countProvider')]
public function testWorkerStopsWhenMaximumCountExceeded(int | {
"filepath": "src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnMessageLimitListenerTest.php",
"language": "php",
"file_size": 2100,
"cut_index": 563,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\EventListener;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attr... | ovider')]
public function testWorkerStopsWhenMemoryLimitExceeded(?int $lastRestartTimeOffset, bool $shouldStop)
{
$cachePool = $this->createMock(CacheItemPoolInterface::class);
$cacheItem = $this->createMock(CacheItemInterface::clas | onent\Messenger\EventListener\StopWorkerOnRestartSignalListener;
use Symfony\Component\Messenger\Worker;
#[Group('time-sensitive')]
class StopWorkerOnRestartSignalListenerTest extends TestCase
{
#[DataProvider('restartTimePr | {
"filepath": "src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnRestartSignalListenerTest.php",
"language": "php",
"file_size": 2861,
"cut_index": 563,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\EventListener;
use PHPUnit\Framework\Attributes\Group;
use PHP... |
public function testWorkerStopsWhenTimeLimitIsReached()
{
$this->expectUserDeprecationMessage('Since symfony/messenger 8.1: "Symfony\Component\Messenger\EventListener\StopWorkerOnTimeLimitListener" is deprecated, use the "time_limit" worke | nger\EventListener\StopWorkerOnTimeLimitListener;
use Symfony\Component\Messenger\Worker;
class StopWorkerOnTimeLimitListenerTest extends TestCase
{
#[Group('time-sensitive')]
#[Group('legacy')]
#[IgnoreDeprecations] | {
"filepath": "src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnTimeLimitListenerTest.php",
"language": "php",
"file_size": 1626,
"cut_index": 537,
"middle_length": 229
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\Handler;
use PHPUnit\Framework\TestCase;
use Symf... | ew \RuntimeException('Ack failed.');
}
++$nackCalls;
$nackError = $error;
};
$acknowledger = new Acknowledger('handler', $ack);
try {
$acknowledger->ack();
} catch (\Runtime | 0;
$nackError = null;
$ack = static function (?\Throwable $error = null) use (&$ackCalls, &$nackCalls, &$nackError): void {
if (null === $error) {
++$ackCalls;
throw n | {
"filepath": "src/Symfony/Component/Messenger/Tests/Handler/AcknowledgerTest.php",
"language": "php",
"file_size": 1387,
"cut_index": 524,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\Handler;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
... | lerString, $descriptor->getName());
}
public static function provideHandlers(): iterable
{
yield [static function () {}, 'Closure'];
yield ['var_dump', 'var_dump'];
yield [new DummyCommandHandler(), DummyCommandHandler: | r('provideHandlers')]
public function testDescriptorNames(callable $handler, ?string $expectedHandlerString)
{
$descriptor = new HandlerDescriptor($handler);
$this->assertStringMatchesFormat($expectedHand | {
"filepath": "src/Symfony/Component/Messenger/Tests/Handler/HandlerDescriptorTest.php",
"language": "php",
"file_size": 2166,
"cut_index": 563,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\Handler;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Envelope;
use S... | r([
DummyMessage::class => [$handler],
]);
$descriptor = new HandlerDescriptor($handler);
$descriptor->getName();
$this->assertEquals([$descriptor], iterator_to_array($locator->getHandlers(new Envelope(new Dumm | ger\Tests\Fixtures\DummyMessage;
class HandlersLocatorTest extends TestCase
{
public function testItYieldsHandlerDescriptors()
{
$handler = new HandlersLocatorTestCallable();
$locator = new HandlersLocato | {
"filepath": "src/Symfony/Component/Messenger/Tests/Handler/HandlersLocatorTest.php",
"language": "php",
"file_size": 2904,
"cut_index": 563,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\Execution;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Envelope;
use... | $acked = false;
$envelope = new Envelope(new DummyMessage('Hello'));
$queue->add($batchHandler, 7, $envelope, $acked, 10.0);
$flushable = $queue->popFlushable(true, 10.0);
$this->assertCount(1, $flushable);
$thi | ssage;
class DeferredBatchMessageQueueTest extends TestCase
{
public function testItReturnsAllEntriesWhenForceFlushing()
{
$queue = new DeferredBatchMessageQueue();
$batchHandler = new \stdClass();
| {
"filepath": "src/Symfony/Component/Messenger/Tests/Execution/DeferredBatchMessageQueueTest.php",
"language": "php",
"file_size": 2318,
"cut_index": 563,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\Retry;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Envelope;
use Symfony... | on testIsNotRetryable()
{
$strategy = new MultiplierRetryStrategy(3);
$envelope = new Envelope(new \stdClass(), [new RedeliveryStamp(3)]);
$this->assertFalse($strategy->isRetryable($envelope));
}
public function testIs | able()
{
$strategy = new MultiplierRetryStrategy(3);
$envelope = new Envelope(new \stdClass(), [new RedeliveryStamp(0)]);
$this->assertTrue($strategy->isRetryable($envelope));
}
public functi | {
"filepath": "src/Symfony/Component/Messenger/Tests/Retry/MultiplierRetryStrategyTest.php",
"language": "php",
"file_size": 4263,
"cut_index": 614,
"middle_length": 229
} |
elope;
use Symfony\Component\Messenger\Handler\HandlersLocator;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Messenger\Middleware\HandleMessageMiddleware;
use Symfony\Component\Messenger\Middleware\MiddlewareInterface;
use Symfony\Component\Messenger\Middleware\StackInterface;
use Symfony\... | xtures\DummyQueryHandler;
use Symfony\Component\Messenger\Tests\Fixtures\MultipleBusesMessage;
use Symfony\Component\Messenger\Tests\Fixtures\MultipleBusesMessageHandler;
use Symfony\Component\Messenger\Tests\Fixtures\SecondMessage;
use Symfony\Component\M | ny\Component\Messenger\Tests\Fixtures\DummyHandlerWithCustomMethods;
use Symfony\Component\Messenger\Tests\Fixtures\DummyMessage;
use Symfony\Component\Messenger\Tests\Fixtures\DummyQuery;
use Symfony\Component\Messenger\Tests\Fi | {
"filepath": "src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php",
"language": "php",
"file_size": 55409,
"cut_index": 2151,
"middle_length": 229
} |
n Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Event;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Stamp\StampInterface;
abstract ... |
/**
* Returns a unique identifier for transport receiver this message was received from.
*/
public function getReceiverName(): string
{
return $this->receiverName;
}
public function addStamps(StampInterface ...$stam | Envelope
{
return $this->envelope;
} | {
"filepath": "src/Symfony/Component/Messenger/Event/AbstractWorkerMessageEvent.php",
"language": "php",
"file_size": 975,
"cut_index": 582,
"middle_length": 52
} |
hp
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Event;
use Symfony\Component\Messenger\Envelop... | ce> $senders
*/
public function __construct(
private Envelope $envelope,
private array $senders,
) {
}
public function getEnvelope(): Envelope
{
return $this->envelope;
}
/**
* @return array<s | as actually
* sent to at least one transport. If the message was sent
* to multiple transports, the event is dispatched only once.
*/
final class MessageSentToTransportsEvent
{
/**
* @param array<string, SenderInterfa | {
"filepath": "src/Symfony/Component/Messenger/Event/MessageSentToTransportsEvent.php",
"language": "php",
"file_size": 1117,
"cut_index": 515,
"middle_length": 229
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Event;
use Symfony\Component\Messenger\Envelope;
use Sy... | s retried.
*
* @author Ryan Weaver <ryan@symfonycasts.com>
*/
final class SendMessageToTransportsEvent
{
/**
* @param array<string, SenderInterface> $senders
*/
public function __construct(
private Envelope $envelope,
p | ally
* be sent to at least one transport. If the message is sent
* to multiple transports, the event is dispatched only once.
* This event is only dispatched the first time a message
* is sent to a transport, not also if it i | {
"filepath": "src/Symfony/Component/Messenger/Event/SendMessageToTransportsEvent.php",
"language": "php",
"file_size": 1391,
"cut_index": 524,
"middle_length": 229
} |
hp
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Event;
use Symfony\Component\Messenger\Envelop... | parent::__construct($envelope, $receiverName);
}
public function getThrowable(): \Throwable
{
return $this->throwable;
}
public function willRetry(): bool
{
return $this->willRetry;
}
public function setF | essageEvent
{
private \Throwable $throwable;
private bool $willRetry = false;
public function __construct(Envelope $envelope, string $receiverName, \Throwable $error)
{
$this->throwable = $error;
| {
"filepath": "src/Symfony/Component/Messenger/Event/WorkerMessageFailedEvent.php",
"language": "php",
"file_size": 1063,
"cut_index": 515,
"middle_length": 229
} |
*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Event;
use Symfony\Component\RateLimiter\LimiterInt... | ivate LimiterInterface $limiter, private string $transportName)
{
}
public function getLimiter(): LimiterInterface
{
return $this->limiter;
}
public function getTransportName(): string
{
return $this->transport | ateLimitedEvent
{
public function __construct(pr | {
"filepath": "src/Symfony/Component/Messenger/Event/WorkerRateLimitedEvent.php",
"language": "php",
"file_size": 842,
"cut_index": 520,
"middle_length": 52
} |
ackage.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Event;
use Symfony\Component\Messenger\Worker;
/**
* Dispatched after the worker process... | }
public function getWorker(): Worker
{
return $this->worker;
}
/**
* Returns true when no message has been received by the worker.
*/
public function isWorkerIdle(): bool
{
return $this->isWorkerIdle | worker,
private bool $isWorkerIdle,
) {
| {
"filepath": "src/Symfony/Component/Messenger/Event/WorkerRunningEvent.php",
"language": "php",
"file_size": 877,
"cut_index": 559,
"middle_length": 52
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Event;
use Symfony\Component\Messenger\Worker;
/**
* ... | a microtime(true) float) at which the
* worker must stop, or null if no --time-limit was set.
*/
public function getDeadline(): ?float
{
return $this->deadline;
}
/**
* Returns the duration in microseconds the worke | ,
private ?float $deadline = null,
private int $idleTimeout = 1000000,
) {
}
public function getWorker(): Worker
{
return $this->worker;
}
/**
* Returns the absolute time (as | {
"filepath": "src/Symfony/Component/Messenger/Event/WorkerStartedEvent.php",
"language": "php",
"file_size": 1307,
"cut_index": 524,
"middle_length": 229
} |
s part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Bridge\AmazonSqs\Transport;
use Symfony\Component\Messenger\Stamp\N... | sageDeduplicationId = null,
) {
}
public function getMessageGroupId(): ?string
{
return $this->messageGroupId;
}
public function getMessageDeduplicationId(): ?string
{
return $this->messageDeduplicationId;
| e ?string $mes | {
"filepath": "src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/AmazonSqsFifoStamp.php",
"language": "php",
"file_size": 810,
"cut_index": 536,
"middle_length": 14
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Bridge\AmazonSqs\Transport;
use AsyncAws\Core\Exception\Http\HttpException;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messe... | ransport\Serialization\PhpSerializer;
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
/**
* @author Jérémy Derussé <jeremy@derusse.com>
*/
class AmazonSqsReceiver implements KeepaliveReceiverInterface, MessageCountAwareInter | senger\Stamp\TransportMessageIdStamp;
use Symfony\Component\Messenger\Transport\Receiver\KeepaliveReceiverInterface;
use Symfony\Component\Messenger\Transport\Receiver\MessageCountAwareInterface;
use Symfony\Component\Messenger\T | {
"filepath": "src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/AmazonSqsReceiver.php",
"language": "php",
"file_size": 3787,
"cut_index": 614,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Bridge\AmazonSqs\Transport;
use AsyncAws\Core\Exception\Http\HttpException;
use Symfony\Compon... | private Connection $connection,
private SerializerInterface $serializer,
) {
}
public function send(Envelope $envelope): Envelope
{
$encodedMessage = $this->serializer->encode($envelope);
$encodedMessage = $th | nterface;
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
/**
* @author Jérémy Derussé <jeremy@derusse.com>
*/
class AmazonSqsSender implements SenderInterface
{
public function __construct(
| {
"filepath": "src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/AmazonSqsSender.php",
"language": "php",
"file_size": 3021,
"cut_index": 563,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Bridge\AmazonSqs\Transport;
use AsyncAws\Core\Exception\Http\HttpException;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messe... | Transport\Sender\SenderInterface;
use Symfony\Component\Messenger\Transport\Serialization\PhpSerializer;
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
use Symfony\Component\Messenger\Transport\SetupableTransportInterface;
use | \Transport\Receiver\KeepaliveReceiverInterface;
use Symfony\Component\Messenger\Transport\Receiver\MessageCountAwareInterface;
use Symfony\Component\Messenger\Transport\Receiver\ReceiverInterface;
use Symfony\Component\Messenger\ | {
"filepath": "src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/AmazonSqsTransport.php",
"language": "php",
"file_size": 3939,
"cut_index": 614,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Bridge\AmazonSqs\Transport;
use Psr\Log\LoggerInterface;
use Symfony... | rtFactoryInterface
{
public function __construct(
private ?LoggerInterface $logger = null,
private ?HttpClientInterface $httpClient = null,
) {
}
public function createTransport(#[\SensitiveParameter] string $dsn, array $op | ace;
use Symfony\Contracts\HttpClient\HttpClientInterface;
/**
* @author Jérémy Derussé <jeremy@derusse.com>
*
* @implements TransportFactoryInterface<AmazonSqsTransport>
*/
class AmazonSqsTransportFactory implements Transpo | {
"filepath": "src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/AmazonSqsTransportFactory.php",
"language": "php",
"file_size": 1537,
"cut_index": 537,
"middle_length": 229
} |
russé <jeremy@derusse.com>
*
* @internal
*
* @final
*/
class Connection
{
private const AWS_SQS_FIFO_SUFFIX = '.fifo';
private const MESSAGE_ATTRIBUTE_NAME = 'X-Symfony-Messenger';
private const DEFAULT_OPTIONS = [
'buffer_size' => 9,
'wait_time' => 20,
'poll_timeout' => 0.1,
... | ,
'account' => null,
'sslmode' => null,
'debug' => null,
];
private array $configuration;
private SqsClient $client;
private ?ReceiveMessageResult $currentResponse = null;
/** @var array[] */
private array $ | ,
'session_token' => null,
'endpoint' => 'https://sqs.eu-west-1.amazonaws.com',
'region' => 'eu-west-1',
'queue_name' => 'messages',
'queue_attributes' => null,
'queue_tags' => null | {
"filepath": "src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/Connection.php",
"language": "php",
"file_size": 17669,
"cut_index": 1331,
"middle_length": 229
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\Transport\Receiver;
use PHPUnit\Framework\TestCas... | $receiver = new SingleMessageReceiver($innerReceiver, $envelope);
$received = $receiver->get();
$this->assertCount(1, $received);
$this->assertSame($received[0], $envelope);
$this->assertSame([], $receiver->get());
| ass SingleMessageReceiverTest extends TestCase
{
public function testItReceivesOnlyOneMessage()
{
$innerReceiver = $this->createStub(ReceiverInterface::class);
$envelope = new Envelope(new \stdClass());
| {
"filepath": "src/Symfony/Component/Messenger/Tests/Transport/Receiver/SingleMessageReceiverTest.php",
"language": "php",
"file_size": 1506,
"cut_index": 524,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\Stamp;
use PHPUnit\Framework\TestCase;
use Symfony\Component\ErrorHandler\Exception\FlattenException;
use Symfony\Component\Messenger\Envel... | Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer as SymfonySerializer;
class ErrorDetailsStampTest extends TestCase
{
public function | lsStamp;
use Symfony\Component\Messenger\Transport\Serialization\Normalizer\FlattenExceptionNormalizer;
use Symfony\Component\Messenger\Transport\Serialization\Serializer;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use | {
"filepath": "src/Symfony/Component/Messenger/Tests/Stamp/ErrorDetailsStampTest.php",
"language": "php",
"file_size": 5061,
"cut_index": 614,
"middle_length": 229
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\Stamp;
use PHPUnit\Framework\TestCase;
use Symfon... | FooHandler::__invoke()', $stamp->getHandlerName());
$stamp = new HandledStamp('some result', 'FooHandler::__invoke()');
$this->assertSame('some result', $stamp->getResult());
$this->assertSame('FooHandler::__invoke()', $stamp->get | extends TestCase
{
public function testConstruct()
{
$stamp = new HandledStamp('some result', 'FooHandler::__invoke()');
$this->assertSame('some result', $stamp->getResult());
$this->assertSame(' | {
"filepath": "src/Symfony/Component/Messenger/Tests/Stamp/HandledStampTest.php",
"language": "php",
"file_size": 1395,
"cut_index": 524,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Tests\Stamp;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Envelope;
use Sym... | blic function testGetSenders()
{
$configuredSenders = ['first_transport', 'second_transport', 'other_transport'];
$stamp = new TransportNamesStamp($configuredSenders);
$stampSenders = $stamp->getTransportNames();
$this-> | ent\Serializer\Normalizer\ArrayDenormalizer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer as SymfonySerializer;
class TransportNamesStampTest extends TestCase
{
pu | {
"filepath": "src/Symfony/Component/Messenger/Tests/Stamp/TransportNamesStampTest.php",
"language": "php",
"file_size": 2170,
"cut_index": 563,
"middle_length": 229
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.