1
0
Fork 0
mirror of https://github.com/archtechx/jobpipeline.git synced 2025-12-12 20:54:04 +00:00

leave only shouldBeQueued method

This commit is contained in:
Jonathan Martins 2023-03-02 14:19:06 -03:00
parent c1e27eae4c
commit ef4ded6e4e
3 changed files with 8 additions and 53 deletions

View file

@ -64,60 +64,14 @@ class JobPipeline implements ShouldQueue
return $this; return $this;
} }
public function shouldBeQueued(bool|string $shouldBeQueued = true) public function shouldBeQueued(bool $shouldBeQueued = true, string $queue = '')
{ {
if (is_string($shouldBeQueued)) $this->shouldBeQueued = $shouldBeQueued;
if ($queue)
{ {
$this->shouldBeQueuedOn($shouldBeQueued); $this->queue = $queue;
} }
else
{
$this->shouldBeQueued = $shouldBeQueued;
}
return $this;
}
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 timeout(int $timeoutInSeconds)
{
$this->timeout = $timeoutInSeconds;
return $this;
}
public function delay($delay)
{
$this->delay = $delay;
return $this;
}
public function tries(int $tries)
{
$this->tries = $tries;
return $this; return $this;
} }

View file

@ -87,7 +87,7 @@ class JobPipelineTest extends TestCase
FooJob::class, FooJob::class,
])->send(function () { ])->send(function () {
return $this->valuestore; return $this->valuestore;
})->shouldBeQueuedOn('another') })->shouldBeQueued(true, 'another')
->toListener()); ->toListener());
$this->assertFalse($this->valuestore->has('foo')); $this->assertFalse($this->valuestore->has('foo'));
@ -106,7 +106,7 @@ class JobPipelineTest extends TestCase
FooJob::class, FooJob::class,
])->send(function () { ])->send(function () {
return $this->valuestore; return $this->valuestore;
})->shouldBeQueuedOn('another') })->shouldBeQueued(true, 'another')
->toListener()); ->toListener());
$this->assertFalse($this->valuestore->has('foo')); $this->assertFalse($this->valuestore->has('foo'));

View file

@ -0,0 +1 @@
{"foo":"bar"}