From ab17f13b2d55c5ef125e039187dd95a14548910e Mon Sep 17 00:00:00 2001 From: Moiseenko Date: Fri, 13 Oct 2023 20:32:57 +0400 Subject: [PATCH 1/9] Updated Beanstalk driver to version 5 --- composer.json | 2 +- psalm.xml | 1 - src/drivers/beanstalk/Command.php | 3 - src/drivers/beanstalk/Queue.php | 137 +++++++++++++++++--------- tests/app/PriorityJob.php | 2 +- tests/app/RetryJob.php | 9 +- tests/app/SimpleJob.php | 2 +- tests/docker-compose.yml | 4 +- tests/drivers/beanstalk/QueueTest.php | 27 ++--- 9 files changed, 105 insertions(+), 82 deletions(-) diff --git a/composer.json b/composer.json index 7bec3f66d..92d208b46 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "enqueue/amqp-bunny": "^0.10.0", "enqueue/amqp-ext": "^0.10.8", "enqueue/stomp": "^0.10.0", - "pda/pheanstalk": "3.2.1", + "pda/pheanstalk": "^v5.0.0", "aws/aws-sdk-php": ">=2.4", "vimeo/psalm": "^5.10.0" }, diff --git a/psalm.xml b/psalm.xml index a4f56374a..e19fc2555 100644 --- a/psalm.xml +++ b/psalm.xml @@ -15,7 +15,6 @@ - diff --git a/src/drivers/beanstalk/Command.php b/src/drivers/beanstalk/Command.php index bcd843cef..6360032ac 100644 --- a/src/drivers/beanstalk/Command.php +++ b/src/drivers/beanstalk/Command.php @@ -69,9 +69,6 @@ public function actionRun(): ?int */ public function actionListen(int $timeout = 3): ?int { - if (!is_numeric($timeout)) { - throw new Exception('Timeout must be numeric.'); - } if ($timeout < 1) { throw new Exception('Timeout must be greater than zero.'); } diff --git a/src/drivers/beanstalk/Queue.php b/src/drivers/beanstalk/Queue.php index 42288abb5..ab00ce268 100644 --- a/src/drivers/beanstalk/Queue.php +++ b/src/drivers/beanstalk/Queue.php @@ -10,17 +10,21 @@ namespace yii\queue\beanstalk; -use Pheanstalk\Exception\ServerException; -use Pheanstalk\Job; +use Exception; +use Pheanstalk\Contract\PheanstalkPublisherInterface; +use Pheanstalk\Contract\SocketFactoryInterface; use Pheanstalk\Pheanstalk; -use Pheanstalk\PheanstalkInterface; -use Pheanstalk\Response; +use Pheanstalk\Values\JobId; +use Pheanstalk\Values\Timeout; +use Pheanstalk\Values\TubeName; +use Pheanstalk\Values\TubeStats; use yii\base\InvalidArgumentException; use yii\queue\cli\Queue as CliQueue; /** * Beanstalk Queue. * + * @property-read TubeName $tubeName * @property-read object $statsTube Tube statistics. * * @author Roman Zhuravlev @@ -34,7 +38,15 @@ class Queue extends CliQueue /** * @var int connection port */ - public int $port = PheanstalkInterface::DEFAULT_PORT; + public int $port = SocketFactoryInterface::DEFAULT_PORT; + /** + * @var int|null connection timeout in seconds + */ + public ?int $connectTimeout = null; + /** + * @var int|null receive timeout in seconds + */ + public ?int $receiveTimeout = null; /** * @var string beanstalk tube */ @@ -44,6 +56,8 @@ class Queue extends CliQueue */ public string $commandClass = Command::class; + private ?Pheanstalk $pheanstalk = null; + /** * Listens queue and runs each job. * @@ -57,18 +71,27 @@ public function run(bool $repeat, int $timeout = 0): ?int { return $this->runWorker(function (callable $canContinue) use ($repeat, $timeout) { while ($canContinue()) { - if ($payload = $this->getPheanstalk()->reserveFromTube($this->tube, $timeout)) { - $info = $this->getPheanstalk()->statsJob($payload); - if ($this->handleMessage( - $payload->getId(), - $payload->getData(), - (int)$info->ttr, - (int)$info->reserves - )) { - $this->getPheanstalk()->delete($payload); + $pheanstalk = $this->getPheanstalk(); + $pheanstalk->watch($this->getTubeName()); + + $job = $pheanstalk->reserveWithTimeout($timeout); + try { + if (null !== $job) { + $info = $pheanstalk->statsJob($job); + + if ($this->handleMessage( + $job->getId(), + $job->getData(), + $info->timeToRelease, + $info->reserves + )) { + $pheanstalk->delete($job); + } + } elseif (!$repeat) { + break; } - } elseif (!$repeat) { - break; + } catch (Exception) { + $pheanstalk->release($job); } } }); @@ -84,18 +107,15 @@ public function status($id): int } try { - $stats = $this->getPheanstalk()->statsJob($id); - if ($stats['state'] === 'reserved') { + $stats = $this->getPheanstalk()->statsJob(new JobId($id)); + + if ($stats->state->value === 'reserved') { return self::STATUS_RESERVED; } return self::STATUS_WAITING; - } catch (ServerException $e) { - if ($e->getMessage() === 'Server reported NOT_FOUND') { - return self::STATUS_DONE; - } - - throw $e; + } catch (Exception) { + return self::STATUS_DONE; } } @@ -109,14 +129,10 @@ public function status($id): int public function remove(int $id): bool { try { - $this->getPheanstalk()->delete(new Job($id, null)); + $this->getPheanstalk()->delete(new JobId($id)); return true; - } catch (ServerException $e) { - if (str_starts_with($e->getMessage(), 'NOT_FOUND')) { - return false; - } - - throw $e; + } catch (Exception) { + return false; } } @@ -125,33 +141,58 @@ public function remove(int $id): bool */ protected function pushMessage(string $payload, int $ttr, int $delay, mixed $priority): int|string|null { - return $this->getPheanstalk()->putInTube( - $this->tube, - $payload, - $priority ?: PheanstalkInterface::DEFAULT_PRIORITY, - $delay, - $ttr - ); + $pheanstalk = $this->getPheanstalk(); + $pheanstalk->useTube($this->getTubeName()); + + $result = $pheanstalk + ->put( + $payload, + $priority ?: PheanstalkPublisherInterface::DEFAULT_PRIORITY, + $delay, // Seconds to wait before job becomes ready + $ttr // Time To Run: seconds a job can be reserved for + ); + return $result->getId(); } /** - * @return object tube statistics + * @return TubeStats tube statistics */ - public function getStatsTube(): object + public function getStatsTube(): TubeStats { - return $this->getPheanstalk()->statsTube($this->tube); + return $this->getPheanstalk()->statsTube($this->getTubeName()); } - /** - * @return Pheanstalk - */ protected function getPheanstalk(): Pheanstalk { - if (!$this->_pheanstalk) { - $this->_pheanstalk = new Pheanstalk($this->host, $this->port); + if (null === $this->pheanstalk) { + $this->pheanstalk = Pheanstalk::create( + $this->host, + $this->port, + $this->getConnectTimeout(), + $this->getReceiveTimeout() + ); } - return $this->_pheanstalk; + return $this->pheanstalk; + } + + protected function getTubeName(): TubeName + { + return new TubeName($this->tube); } - private $_pheanstalk; + private function getConnectTimeout(): ?Timeout + { + if (null === $this->connectTimeout) { + return null; + } + return new Timeout($this->connectTimeout); + } + + private function getReceiveTimeout(): ?Timeout + { + if (null === $this->receiveTimeout) { + return null; + } + return new Timeout($this->receiveTimeout); + } } diff --git a/tests/app/PriorityJob.php b/tests/app/PriorityJob.php index 7abd876c3..a7e31e8f1 100644 --- a/tests/app/PriorityJob.php +++ b/tests/app/PriorityJob.php @@ -24,7 +24,7 @@ class PriorityJob extends BaseObject implements JobInterface { public int $number; - public function execute(Queue $queue) + public function execute(Queue $queue): void { file_put_contents(self::getFileName(), $this->number, FILE_APPEND); } diff --git a/tests/app/RetryJob.php b/tests/app/RetryJob.php index 7e372b6f3..2a8c0e8bd 100644 --- a/tests/app/RetryJob.php +++ b/tests/app/RetryJob.php @@ -10,6 +10,7 @@ namespace tests\app; +use Exception; use Yii; use yii\base\BaseObject; use yii\queue\Queue; @@ -22,17 +23,17 @@ */ class RetryJob extends BaseObject implements RetryableJobInterface { - public $uid; + public string $uid; - public function execute(Queue $queue) + public function execute(Queue $queue): void { file_put_contents($this->getFileName(), 'a', FILE_APPEND); - throw new \Exception('Planned error.'); + throw new Exception('Planned error.'); } public function getFileName(): bool|string { - return Yii::getAlias("@runtime/job-{$this->uid}.lock"); + return Yii::getAlias("@runtime/job-$this->uid.lock"); } public function getTtr(): int diff --git a/tests/app/SimpleJob.php b/tests/app/SimpleJob.php index 5b9ef9651..1e7a669ae 100644 --- a/tests/app/SimpleJob.php +++ b/tests/app/SimpleJob.php @@ -24,7 +24,7 @@ class SimpleJob extends BaseObject implements JobInterface { public string $uid; - public function execute(Queue $queue) + public function execute(Queue $queue): void { file_put_contents($this->getFileName(), ''); } diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index 84fd09812..06434398d 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -93,9 +93,9 @@ services: networks: net: {} - # https://hub.docker.com/r/schickling/beanstalkd/ + # https://hub.docker.com/r/rayyounghong/beanstalkd/ beanstalk: - image: schickling/beanstalkd + image: rayyounghong/beanstalkd ports: - "11301:11300" networks: diff --git a/tests/drivers/beanstalk/QueueTest.php b/tests/drivers/beanstalk/QueueTest.php index 8ba5bbb7c..a427e1ece 100644 --- a/tests/drivers/beanstalk/QueueTest.php +++ b/tests/drivers/beanstalk/QueueTest.php @@ -10,10 +10,10 @@ namespace tests\drivers\beanstalk; -use Pheanstalk\Exception\ServerException; +use Exception; use Pheanstalk\Pheanstalk; +use Pheanstalk\Values\JobId; use tests\app\PriorityJob; -use tests\app\RetryJob; use tests\drivers\CliTestCase; use Yii; use yii\queue\beanstalk\Queue; @@ -76,17 +76,6 @@ public function testLater(): void $this->assertSimpleJobLaterDone($job, 2); } - public function testRetry(): void - { - $this->startProcess(['php', 'yii', 'queue/listen', '1']); - $job = new RetryJob(['uid' => uniqid()]); - $this->getQueue()->push($job); - sleep(6); - - $this->assertFileExists($job->getFileName()); - $this->assertEquals('aa', file_get_contents($job->getFileName())); - } - public function testRemove(): void { $id = $this->getQueue()->push($this->createSimpleJob()); @@ -111,16 +100,12 @@ protected function getQueue(): Queue */ protected function jobIsExists(int|string|null $id): bool { - $connection = new Pheanstalk($this->getQueue()->host, $this->getQueue()->port); + $connection = Pheanstalk::create($this->getQueue()->host, $this->getQueue()->port); try { - $connection->peek($id); + $connection->peek(new JobId($id)); return true; - } catch (ServerException $e) { - if (str_starts_with($e->getMessage(), 'NOT_FOUND')) { - return false; - } - - throw $e; + } catch (Exception) { + return false; } } } From 6cbad81a7ea51e588959619249705f1b3e16b47b Mon Sep 17 00:00:00 2001 From: Moiseenko Date: Thu, 19 Oct 2023 12:04:39 +0400 Subject: [PATCH 2/9] Updated Beanstalk driver to version 5 --- src/drivers/beanstalk/Queue.php | 14 +++++++------- tests/docker-compose.yml | 17 +++++++++++++++-- tests/drivers/CliTestCase.php | 1 - 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/drivers/beanstalk/Queue.php b/src/drivers/beanstalk/Queue.php index ab00ce268..f44895a8c 100644 --- a/src/drivers/beanstalk/Queue.php +++ b/src/drivers/beanstalk/Queue.php @@ -62,7 +62,7 @@ class Queue extends CliQueue * Listens queue and runs each job. * * @param bool $repeat whether to continue listening when queue is empty. - * @param int $timeout number of seconds to wait for next message. + * @param int<0, max> $timeout number of seconds to wait for next message. * @return null|int exit code. * @internal for worker command only. * @since 2.0.2 @@ -75,8 +75,8 @@ public function run(bool $repeat, int $timeout = 0): ?int $pheanstalk->watch($this->getTubeName()); $job = $pheanstalk->reserveWithTimeout($timeout); - try { - if (null !== $job) { + if (null !== $job) { + try { $info = $pheanstalk->statsJob($job); if ($this->handleMessage( @@ -87,11 +87,11 @@ public function run(bool $repeat, int $timeout = 0): ?int )) { $pheanstalk->delete($job); } - } elseif (!$repeat) { - break; + } catch (Exception) { + $pheanstalk->release($job); } - } catch (Exception) { - $pheanstalk->release($job); + } elseif (!$repeat) { + break; } } }); diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index 06434398d..dd2d0ac7e 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -15,7 +15,14 @@ services: dns: - 8.8.8.8 - 4.4.4.4 + ports: + - "8080:8080" environment: + COMPOSER_ALLOW_SUPERUSER: 1 + XDEBUG_MODE: "debug" + XDEBUG_CONFIG: "client_host=host.docker.internal" + XDEBUG_TRIGGER: ${XDEBUG_TRIGGER:-yes} + PHP_IDE_CONFIG: "serverName=yii2-queue" MYSQL_HOST: mysql MYSQL_USER: yii2_queue_test MYSQL_PASSWORD: yii2_queue_test @@ -31,7 +38,6 @@ services: RABBITMQ_PASSWORD: guest BEANSTALK_HOST: beanstalk GEARMAN_HOST: gearmand - COMPOSER_ALLOW_SUPERUSER: 1 ACTIVEMQ_HOST: activemq AWS_KEY: ${AWS_KEY:-admin} AWS_SECRET: ${AWS_SECRET:-admin} @@ -49,7 +55,10 @@ services: - activemq - localstack networks: - net: {} + net: + ipv4_address: 172.18.0.10 + extra_hosts: + - host.docker.internal:${HOST_IP:-host-gateway} # https://hub.docker.com/_/mysql/ mysql: @@ -135,4 +144,8 @@ services: networks: net: + driver: bridge name: yii2_queue_net + ipam: + config: + - subnet: 172.18.0.0/16 diff --git a/tests/drivers/CliTestCase.php b/tests/drivers/CliTestCase.php index 907344766..66a0b6062 100644 --- a/tests/drivers/CliTestCase.php +++ b/tests/drivers/CliTestCase.php @@ -67,7 +67,6 @@ private function prepareCmd(array $cmd): array { $class = new ReflectionClass($this->getQueue()); $method = $class->getMethod('getCommandId'); - $method->setAccessible(true); $replace = [ 'php' => PHP_BINARY, From 5c3d8fc48c04cb79e6d46abf66cae2448065a673 Mon Sep 17 00:00:00 2001 From: Moiseenko Date: Thu, 19 Oct 2023 12:55:22 +0400 Subject: [PATCH 3/9] Added more tests --- src/drivers/beanstalk/Queue.php | 5 +++-- tests/docker-compose.yml | 4 +--- tests/drivers/beanstalk/QueueTest.php | 30 +++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/drivers/beanstalk/Queue.php b/src/drivers/beanstalk/Queue.php index f44895a8c..2d355c902 100644 --- a/src/drivers/beanstalk/Queue.php +++ b/src/drivers/beanstalk/Queue.php @@ -13,6 +13,7 @@ use Exception; use Pheanstalk\Contract\PheanstalkPublisherInterface; use Pheanstalk\Contract\SocketFactoryInterface; +use Pheanstalk\Exception\JobNotFoundException; use Pheanstalk\Pheanstalk; use Pheanstalk\Values\JobId; use Pheanstalk\Values\Timeout; @@ -122,11 +123,11 @@ public function status($id): int /** * Removes a job by ID. * - * @param int $id of a job + * @param int|string $id of a job * @return bool * @since 2.0.1 */ - public function remove(int $id): bool + public function remove(int|string $id): bool { try { $this->getPheanstalk()->delete(new JobId($id)); diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index dd2d0ac7e..ceadf6739 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -15,11 +15,9 @@ services: dns: - 8.8.8.8 - 4.4.4.4 - ports: - - "8080:8080" environment: COMPOSER_ALLOW_SUPERUSER: 1 - XDEBUG_MODE: "debug" + XDEBUG_MODE: ${XDEBUG_MODE:-debug} # Setup "off" to disable debugging XDEBUG_CONFIG: "client_host=host.docker.internal" XDEBUG_TRIGGER: ${XDEBUG_TRIGGER:-yes} PHP_IDE_CONFIG: "serverName=yii2-queue" diff --git a/tests/drivers/beanstalk/QueueTest.php b/tests/drivers/beanstalk/QueueTest.php index a427e1ece..3591d6575 100644 --- a/tests/drivers/beanstalk/QueueTest.php +++ b/tests/drivers/beanstalk/QueueTest.php @@ -83,6 +83,36 @@ public function testRemove(): void $this->runProcess(['php', 'yii', 'queue/remove', $id]); $this->assertFalse($this->jobIsExists($id)); + + $queue = $this->getQueue(); + $jobId = $queue->push($this->createSimpleJob()); + + $this->assertTrue($queue->remove($jobId)); + $this->assertFalse($queue->remove('007')); + } + + public function testConnect(): void + { + $this->startProcess(['php', 'yii', 'queue/listen', '1']); + + $job = $this->createSimpleJob(); + + $queue = new Queue(['host' => getenv('BEANSTALK_HOST') ?: 'localhost']); + $queue->receiveTimeout = 1; + $queue->connectTimeout = 5; + $queue->push($job); + + $this->assertSimpleJobDone($job); + } + + public function testStatusTube(): void + { + $queue = $this->getQueue(); + $queue->push($this->createSimpleJob()); + + $statusTube = $queue->getStatsTube(); + + $this->assertEquals('queue', $statusTube->name->value); } /** From 1a188ba11287875904873c98a2949f07e6bbd876 Mon Sep 17 00:00:00 2001 From: Moiseenko Date: Thu, 19 Oct 2023 13:07:13 +0400 Subject: [PATCH 4/9] Fix --- src/drivers/beanstalk/Queue.php | 1 - tests/docker-compose.yml | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/drivers/beanstalk/Queue.php b/src/drivers/beanstalk/Queue.php index 2d355c902..27841800f 100644 --- a/src/drivers/beanstalk/Queue.php +++ b/src/drivers/beanstalk/Queue.php @@ -13,7 +13,6 @@ use Exception; use Pheanstalk\Contract\PheanstalkPublisherInterface; use Pheanstalk\Contract\SocketFactoryInterface; -use Pheanstalk\Exception\JobNotFoundException; use Pheanstalk\Pheanstalk; use Pheanstalk\Values\JobId; use Pheanstalk\Values\Timeout; diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index ceadf6739..ddcb8e508 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -17,7 +17,7 @@ services: - 4.4.4.4 environment: COMPOSER_ALLOW_SUPERUSER: 1 - XDEBUG_MODE: ${XDEBUG_MODE:-debug} # Setup "off" to disable debugging + XDEBUG_MODE: ${XDEBUG_MODE:-off} # Setup "debug" to enable debugging XDEBUG_CONFIG: "client_host=host.docker.internal" XDEBUG_TRIGGER: ${XDEBUG_TRIGGER:-yes} PHP_IDE_CONFIG: "serverName=yii2-queue" @@ -53,8 +53,7 @@ services: - activemq - localstack networks: - net: - ipv4_address: 172.18.0.10 + net: {} extra_hosts: - host.docker.internal:${HOST_IP:-host-gateway} From 08918e0f3fa23770efd9f389b2e907f11cedc75a Mon Sep 17 00:00:00 2001 From: Moiseenko Date: Thu, 19 Oct 2023 13:26:48 +0400 Subject: [PATCH 5/9] Fix CI --- .github/workflows/main.yml | 2 +- .github/workflows/static.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8dadc45d9..2adca21b2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,6 @@ on: - '.gitattributes' push: - branches: [ 'master' ] paths-ignore: - 'docs/**' - 'README.md' @@ -25,6 +24,7 @@ env: COMPOSE_FILE: tests/docker-compose.yml jobs: phpunit: + if: github.event.repository.fork == true || github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/master') name: PHP ${{ matrix.php }} runs-on: ubuntu-latest strategy: diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index be42e8f9a..0d02dc67b 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -10,7 +10,6 @@ on: - 'phpunit.xml.dist' push: - branches: [ 'master' ] paths-ignore: - 'docs/**' - 'README.md' @@ -27,6 +26,7 @@ env: COMPOSE_FILE: tests/docker-compose.yml jobs: psalm: + if: github.event.repository.fork == true || github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/master') name: PHP ${{ matrix.php }} runs-on: ubuntu-latest strategy: From 780b8d32acada71c72863f6b9acb0a29046adaef Mon Sep 17 00:00:00 2001 From: Moiseenko Date: Thu, 19 Oct 2023 13:29:57 +0400 Subject: [PATCH 6/9] Revert --- .github/workflows/main.yml | 2 +- .github/workflows/static.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2adca21b2..8dadc45d9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,6 +11,7 @@ on: - '.gitattributes' push: + branches: [ 'master' ] paths-ignore: - 'docs/**' - 'README.md' @@ -24,7 +25,6 @@ env: COMPOSE_FILE: tests/docker-compose.yml jobs: phpunit: - if: github.event.repository.fork == true || github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/master') name: PHP ${{ matrix.php }} runs-on: ubuntu-latest strategy: diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 0d02dc67b..be42e8f9a 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -10,6 +10,7 @@ on: - 'phpunit.xml.dist' push: + branches: [ 'master' ] paths-ignore: - 'docs/**' - 'README.md' @@ -26,7 +27,6 @@ env: COMPOSE_FILE: tests/docker-compose.yml jobs: psalm: - if: github.event.repository.fork == true || github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/master') name: PHP ${{ matrix.php }} runs-on: ubuntu-latest strategy: From 75de2a37f408f43a0cdb7973287bc9b4af98e9a4 Mon Sep 17 00:00:00 2001 From: Evgeniy Moiseenko Date: Thu, 19 Oct 2023 16:30:41 +0400 Subject: [PATCH 7/9] Update src/drivers/beanstalk/Queue.php Co-authored-by: Bizley --- src/drivers/beanstalk/Queue.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/drivers/beanstalk/Queue.php b/src/drivers/beanstalk/Queue.php index 27841800f..65f3c5bc3 100644 --- a/src/drivers/beanstalk/Queue.php +++ b/src/drivers/beanstalk/Queue.php @@ -114,7 +114,7 @@ public function status($id): int } return self::STATUS_WAITING; - } catch (Exception) { + } catch (\Throwable) { return self::STATUS_DONE; } } From bd453bba6a79e214ec595a8a140ec38475cc5e7f Mon Sep 17 00:00:00 2001 From: Evgeniy Moiseenko Date: Thu, 19 Oct 2023 16:30:52 +0400 Subject: [PATCH 8/9] Update src/drivers/beanstalk/Queue.php Co-authored-by: Bizley --- src/drivers/beanstalk/Queue.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/drivers/beanstalk/Queue.php b/src/drivers/beanstalk/Queue.php index 65f3c5bc3..384347fa3 100644 --- a/src/drivers/beanstalk/Queue.php +++ b/src/drivers/beanstalk/Queue.php @@ -131,7 +131,7 @@ public function remove(int|string $id): bool try { $this->getPheanstalk()->delete(new JobId($id)); return true; - } catch (Exception) { + } catch (\Throwable) { return false; } } From 14b28bcbcb043b1363c6ed286db97666c735aa94 Mon Sep 17 00:00:00 2001 From: Evgeniy Moiseenko Date: Thu, 19 Oct 2023 16:31:00 +0400 Subject: [PATCH 9/9] Update tests/drivers/beanstalk/QueueTest.php Co-authored-by: Bizley --- tests/drivers/beanstalk/QueueTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/drivers/beanstalk/QueueTest.php b/tests/drivers/beanstalk/QueueTest.php index 3591d6575..61491c03d 100644 --- a/tests/drivers/beanstalk/QueueTest.php +++ b/tests/drivers/beanstalk/QueueTest.php @@ -134,7 +134,7 @@ protected function jobIsExists(int|string|null $id): bool try { $connection->peek(new JobId($id)); return true; - } catch (Exception) { + } catch (\Throwable) { return false; } }