8000 Revert ":sparkles: [53543] Implement support for resetting messenger … · symfony/symfony@5ce08a2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5ce08a2

Browse files
committed
Revert ":sparkles: [53543] Implement support for resetting messenger transports"
This reverts commit 02442c9.
1 parent 6e905a9 commit 5ce08a2

File tree

3 files changed

+6
-15
lines changed
10000

3 files changed

+6
-15
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2372,7 +2372,6 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder
23722372
->setFactory([new Reference('messenger.transport_factory'), 'createTransport'])
23732373
->setArguments([$transport['dsn'], $transport['options'] + ['transport_name' => $name], new Reference($serializerId)])
23742374
->addTag('messenger.receiver', $tags)
2375-
->addTag('kernel.reset', ['method' => 'reset', 'on_invalid' => 'ignore'])
23762375
;
23772376
$container->setDefinition($transportId = 'messenger.transport.'.$name, $transportDefinition);
23782377
$senderAliases[$name] = $transportId;

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,6 @@ public function testMessengerTransports()
948948
$container = $this->createContainerFromFile('messenger_transports');
949949
$this->assertTrue($container->hasDefinition('messenger.transport.default'));
950950
$this->assertTrue($container->getDefinition('messenger.transport.default')->hasTag('messenger.receiver'));
951-
$this->assertTrue($container->getDefinition('messenger.transport.default')->hasTag('kernel.reset'));
952951
$this->assertEquals([
953952
['alias' => 'default', 'is_failure_transport' => false], ], $container->getDefinition('messenger.transport.default')->getTag('messenger.receiver'));
954953
$transportArguments = $container->getDefinition('messenger.transport.default')->getArguments();

src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Symfony\Component\Messenger\Exception\InvalidArgumentException;
1717
use Symfony\Component\Messenger\Exception\LogicException;
1818
use Symfony\Component\Messenger\Exception\TransportException;
19-
use Symfony\Contracts\Service\ResetInterface;
2019

2120
/**
2221
* A Redis connection.
@@ -29,7 +28,7 @@
2928
*
3029
* @final
3130
*/
32-
class Connection implements ResetInterface
31+
class Connection
3332
{
3433
private const DEFAULT_OPTIONS = [
3534
'host' => '127.0.0.1',
@@ -56,8 +55,7 @@ class Connection implements ResetInterface
5655
'ssl' => null, // see https://php.net/context.ssl
5756
];
5857

59-
private \Redis|Relay|\RedisCluster|null $redis = null;
60-
private \Closure $redisInitializer;
58+
private \Redis|Relay|\RedisCluster|\Closure $redis;
6159
private string $stream;
6260
private string $queue;
6361
private string $group;
@@ -114,9 +112,9 @@ public function __construct(array $options, \Redis|Relay|\RedisCluster|null $red
114112

115113
if ((\is_array($host) && null === $sentinelMaster) || $redis instanceof \RedisCluster) {
116114
$hosts = \is_string($host) ? [$host.':'.$port] : $host; // Always ensure we have an array
117-
$this->redisInitializer = static fn () => self::initializeRedisCluster($redis, $hosts, $auth, $options);
115+
$this->redis = static fn () => self::initializeRedisCluster($redis, $hosts, $auth, $options);
118116
} else {
119-
$this->redisInitializer = static function () use ($redis, $sentinelMaster, $host, $port, $options, $auth) {
117+
$this->redis = static function () use ($redis, $sentinelMaster, $host, $port, $options, $auth) {
120118
if (null !== $sentinelMaster) {
121119
$sentinelClass = \extension_loaded('redis') ? \RedisSentinel::class : Sentinel::class;
122120
$hostIndex = 0;
@@ -739,15 +737,10 @@ private function rawCommand(string $command, ...$arguments): mixed
739737

740738
private function getRedis(): \Redis|Relay|\RedisCluster
741739
{
742-
if (!$this->redis) {
743-
$this->redis = ($this->redisInitializer)();
740+
if ($this->redis instanceof \Closure) {
741+
$this->redis = ($this->redis)();
744742
}
745743

746744
return $this->redis;
747745
}
748-
749-
public function reset(): void
750-
{
751-
$this->redis = null;
752-
}
753746
}

0 commit comments

Comments
 (0)
0