From 7e618f6950e334b1eab3e298f43ecf8ec59389f9 Mon Sep 17 00:00:00 2001 From: Jonathan Martins Date: Sat, 25 Feb 2023 11:49:51 -0300 Subject: [PATCH] The following methods where added: onConnection, onQueue, delay, tries, shouldBeQueuedOn. The signature of shouldBeQueued was changed too. --- src/JobPipeline.php | 58 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 7 deletions(-) diff --git a/src/JobPipeline.php b/src/JobPipeline.php index 8e69dce..6ab0ebb 100644 --- a/src/JobPipeline.php +++ b/src/JobPipeline.php @@ -25,10 +25,16 @@ class JobPipeline implements ShouldQueue public $passable; /** @var bool */ - public $shouldBeQueued; - + public bool $shouldBeQueued; + /** @var string */ - public $queue; + public string|null $queue; + + /** @var string */ + public string|null $connection; + + /** @var int */ + public int $tries = 1; public function __construct($jobs, callable $send = null, bool $shouldBeQueued = null) { @@ -53,20 +59,58 @@ class JobPipeline implements ShouldQueue return $this; } - public function shouldBeQueued(bool $shouldBeQueued = true) + public function shouldBeQueued(bool|string $shouldBeQueued = true) { - $this->shouldBeQueued = $shouldBeQueued; + if (is_string($shouldBeQueued)) + { + $this->onQueue($shouldBeQueued); + $this->shouldBeQueued = true; + } + else + { + $this->shouldBeQueued = $shouldBeQueued; + } return $this; } - - public function onQueue(string $queue) + + public function shouldBeQueuedOn(string $queue) + { + $this->shouldBeQueued = true; + + $this->onQueue($queue); + + return $this; + } + + public function onConnection(null|string $connection) + { + $this->connection = $connection; + + return $this; + } + + public function onQueue(null|string $queue) { $this->queue = $queue; return $this; } + public function delay($delay) + { + $this->delay = $delay; + + return $this; + } + + public function tries($tries) + { + $this->tries = $tries; + + return $this; + } + public function handle(): void { foreach ($this->jobs as $job) {