Skip to content

Commit

Permalink
Merge options from dsn with passed options
Browse files Browse the repository at this point in the history
  • Loading branch information
grachevko committed Jun 9, 2021
1 parent 28df682 commit 2b9e41a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Messenger/NsqTransportFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,18 @@ public function __construct(LoggerInterface $logger = null)
*/
public function createTransport(string $dsn, array $options, SerializerInterface $serializer): TransportInterface
{
if (false === $parsedUrl = parse_url($dsn)) {
if (false === $components = parse_url($dsn)) {
throw new InvalidArgumentException(sprintf('The given Nsq DSN "%s" is invalid.', $dsn));
}

$nsqOptions = [];
if (isset($parsedUrl['query'])) {
parse_str($parsedUrl['query'], $nsqOptions);
$query = [];
if (isset($components['query'])) {
parse_str($components['query'], $query);
}

$address = sprintf('tcp://%s:%s', $parsedUrl['host'] ?? 'nsqd', $parsedUrl['port'] ?? 4150);
$nsqOptions = $query + $options;

$address = sprintf('tcp://%s:%s', $components['host'], $components['port'] ?? $query['port'] ?? 4150);
$topic = $nsqOptions['topic'] ?? 'symfony-messenger';
$channel = $nsqOptions['channel'] ?? 'default';

Expand Down

0 comments on commit 2b9e41a

Please sign in to comment.