[Messenger] Make sure redis transports are initialized correctly
This commit is contained in:
parent
b3333e552d
commit
68b3b898d8
@ -62,6 +62,14 @@ class ConnectionTest extends TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFromDsnWithOptionsAndTrailingSlash()
|
||||||
|
{
|
||||||
|
$this->assertEquals(
|
||||||
|
Connection::fromDsn('redis://localhost/', ['stream' => 'queue', 'group' => 'group1', 'consumer' => 'consumer1', 'auto_setup' => false, 'serializer' => 2]),
|
||||||
|
Connection::fromDsn('redis://localhost/queue/group1/consumer1?serializer=2&auto_setup=0')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function testFromDsnWithQueryOptions()
|
public function testFromDsnWithQueryOptions()
|
||||||
{
|
{
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
|
@ -63,6 +63,12 @@ class Connection
|
|||||||
throw new InvalidArgumentException('Redis connection failed: '.$redis->getLastError());
|
throw new InvalidArgumentException('Redis connection failed: '.$redis->getLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (['stream', 'group', 'consumer'] as $key) {
|
||||||
|
if (isset($configuration[$key]) && '' === $configuration[$key]) {
|
||||||
|
throw new InvalidArgumentException(sprintf('"%s" should be configured, got an empty string.', $key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->stream = $configuration['stream'] ?? self::DEFAULT_OPTIONS['stream'];
|
$this->stream = $configuration['stream'] ?? self::DEFAULT_OPTIONS['stream'];
|
||||||
$this->group = $configuration['group'] ?? self::DEFAULT_OPTIONS['group'];
|
$this->group = $configuration['group'] ?? self::DEFAULT_OPTIONS['group'];
|
||||||
$this->consumer = $configuration['consumer'] ?? self::DEFAULT_OPTIONS['consumer'];
|
$this->consumer = $configuration['consumer'] ?? self::DEFAULT_OPTIONS['consumer'];
|
||||||
@ -77,7 +83,7 @@ class Connection
|
|||||||
throw new InvalidArgumentException(sprintf('The given Redis DSN "%s" is invalid.', $dsn));
|
throw new InvalidArgumentException(sprintf('The given Redis DSN "%s" is invalid.', $dsn));
|
||||||
}
|
}
|
||||||
|
|
||||||
$pathParts = explode('/', $parsedUrl['path'] ?? '');
|
$pathParts = explode('/', rtrim($parsedUrl['path'] ?? '', '/'));
|
||||||
|
|
||||||
$stream = $pathParts[1] ?? $redisOptions['stream'] ?? null;
|
$stream = $pathParts[1] ?? $redisOptions['stream'] ?? null;
|
||||||
$group = $pathParts[2] ?? $redisOptions['group'] ?? null;
|
$group = $pathParts[2] ?? $redisOptions['group'] ?? null;
|
||||||
|
Reference in New Issue
Block a user