mirror of
https://github.com/archtechx/jobpipeline.git
synced 2025-12-12 15:14:04 +00:00
Add $queue attribute
This code enables me to change the queue name that the JobPipeline will be pushed to.
Now I can do something like this:
```php
JobPipeline::make([
Jobs\CreateDatabase::class,
Jobs\MigrateDatabase::class,
// Jobs\SeedDatabase::class,
// Your own jobs to prepare the tenant.
// Provision API keys, create S3 buckets, anything you want!
])->send(function (Events\TenantCreated $event)
{
return $event->tenant;
})->onQueue('another-queue')
->shouldBeQueued()
```
This commit is contained in:
parent
bfc53f6dd6
commit
c75c76e49a
1 changed files with 10 additions and 0 deletions
|
|
@ -27,6 +27,9 @@ class JobPipeline implements ShouldQueue
|
|||
/** @var bool */
|
||||
public $shouldBeQueued;
|
||||
|
||||
/** @var string */
|
||||
public $queue;
|
||||
|
||||
public function __construct($jobs, callable $send = null, bool $shouldBeQueued = null)
|
||||
{
|
||||
$this->jobs = $jobs;
|
||||
|
|
@ -57,6 +60,13 @@ class JobPipeline implements ShouldQueue
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function onQueue(string $queue)
|
||||
{
|
||||
$this->queue = $queue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
foreach ($this->jobs as $job) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue