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

Possibility to change the default configurations for the queue jobs. (#13)

* 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()
```

* Add .idea directory to gitignore

* The following methods where added: onConnection, onQueue, delay, tries, shouldBeQueuedOn. The signature of shouldBeQueued was changed too.

* reuse shouldBeQueuedOn

* updating docs

* added timeout

* docs updated

* .phpunit.cache/ added to gitignore

* tests for shouldQueueOn method

* leave only shouldBeQueued method

* update README

* remove unnecessary property declarations

* Delete  jobpipelinetest.json

* add jobpipelinetest.json as a empty file

* update readme

* simplify tests

* improve code

* improve readme

---------

Co-authored-by: Samuel Štancl <samuel@archte.ch>
This commit is contained in:
Jonathan Prass Martins 2023-03-16 18:14:36 -03:00 committed by GitHub
parent bfc53f6dd6
commit d7a9e6796e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 58 additions and 3 deletions

View file

@ -25,7 +25,10 @@ class JobPipeline implements ShouldQueue
public $passable;
/** @var bool */
public $shouldBeQueued;
public bool $shouldBeQueued;
/** @var string */
public string $queue;
public function __construct($jobs, callable $send = null, bool $shouldBeQueued = null)
{
@ -50,10 +53,14 @@ class JobPipeline implements ShouldQueue
return $this;
}
public function shouldBeQueued(bool $shouldBeQueued = true)
public function shouldBeQueued(bool $shouldBeQueued = true, string $queue = null)
{
$this->shouldBeQueued = $shouldBeQueued;
if ($queue) {
$this->queue = $queue;
}
return $this;
}