Skip to content

chore: CATALOG-11541 Use catalog changes in fork repo #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
"php-amqplib/php-amqplib": "^v3.6"
},
"require-dev": {
"phpunit/phpunit": "^10.0|^11.0",
"phpunit/phpunit": "^11.0",
"mockery/mockery": "^1.0",
"laravel/horizon": "^5.0",
"orchestra/testbench": "^7.0|^8.0|^9.0|^10.0",
"laravel/pint": "^1.2",
"laravel/framework": "^9.0|^10.0|^11.0|^12.0"
"laravel/framework": "^11.0|^12.0"
},
"autoload": {
"psr-4": {
Expand All @@ -33,9 +33,6 @@
}
},
"extra": {
"branch-alias": {
"dev-master": "13.0-dev"
},
"laravel": {
"providers": [
"VladimirYuldashev\\LaravelQueueRabbitMQ\\LaravelQueueRabbitMQServiceProvider"
Expand Down
41 changes: 33 additions & 8 deletions src/Queue/Connection/ConfigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,21 @@ public static function make(array $config = []): AMQPConnectionConfig
{
return tap(new AMQPConnectionConfig, function (AMQPConnectionConfig $connectionConfig) use ($config) {
// Set the connection to a Lazy by default
$connectionConfig->setIsLazy(! in_array(
Arr::get($config, 'lazy') ?? true,
[false, 0, '0', 'false', 'no'],
true)
$connectionConfig->setIsLazy(
! in_array(
Arr::get($config, 'lazy') ?? true,
[false, 0, '0', 'false', 'no'],
true
)
);

// Set the connection to unsecure by default
$connectionConfig->setIsSecure(in_array(
Arr::get($config, 'secure'),
[true, 1, '1', 'true', 'yes'],
true)
$connectionConfig->setIsSecure(
in_array(
Arr::get($config, 'secure'),
[true, 1, '1', 'true', 'yes'],
true
)
);

if ($connectionConfig->isSecure()) {
Expand All @@ -38,6 +42,7 @@ public static function make(array $config = []): AMQPConnectionConfig
self::getHostFromConfig($connectionConfig, $config);
self::getHeartbeatFromConfig($connectionConfig, $config);
self::getNetworkProtocolFromConfig($connectionConfig, $config);
self::getReadWriteTimeoutFromConfig($connectionConfig, $config);
});
}

Expand Down Expand Up @@ -99,4 +104,24 @@ protected static function getNetworkProtocolFromConfig(AMQPConnectionConfig $con
$connectionConfig->setNetworkProtocol($networkProtocol);
}
}

protected static function getReadWriteTimeoutFromConfig(AMQPConnectionConfig $connectionConfig, array $config): void
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add tests 🙏

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

{
$readTimeout = Arr::get($config, self::CONFIG_OPTIONS.'.read_timeout');
$writeTimeout = Arr::get($config, self::CONFIG_OPTIONS.'.write_timeout');

if (is_numeric($readTimeout)) {
$timeoutValue = (int) $readTimeout;
if ($timeoutValue > 0) {
$connectionConfig->setReadTimeout($timeoutValue);
}
}

if (is_numeric($writeTimeout)) {
$timeoutValue = (int) $writeTimeout;
if ($timeoutValue > 0) {
$connectionConfig->setWriteTimeout($timeoutValue);
}
}
}
}
6 changes: 5 additions & 1 deletion tests/Feature/ConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ public function test_no_verification_ssl_connection(): void
'verify_peer' => false,
'passphrase' => null,
],
'read_timeout' => 10,
'write_timeout' => 15,
],

'worker' => env('RABBITMQ_WORKER', 'default'),
Expand All @@ -180,8 +182,10 @@ public function test_no_verification_ssl_connection(): void
$connection = $queue->connection('rabbitmq');
$this->assertInstanceOf(RabbitMQQueue::class, $connection);
$this->assertInstanceOf(AMQPSSLConnection::class, $connection->getConnection());
/** @var AMQPConnectionConfig */
/** @var AMQPConnectionConfig $config */
$config = $connection->getConnection()->getConfig();
$this->assertFalse($config->getSslVerify());
$this->assertEquals(10, $config->getReadTimeout());
$this->assertEquals(15, $config->getWriteTimeout());
}
}