Updates to Jobs so they are all queable, and overlapping is consistent

This commit is contained in:
Deon George 2024-10-01 11:48:17 +10:00
parent 4828cc6e84
commit a2c71afa73
3 changed files with 26 additions and 3 deletions

View File

@ -2,6 +2,8 @@
namespace App\Jobs;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Queue\Middleware\WithoutOverlapping;
use Illuminate\Support\Facades\Log;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
@ -11,7 +13,7 @@ use App\Models\Abstracted\Catalog;
class CatalogDelete implements ShouldQueue
{
use InteractsWithQueue,SerializesModels;
use InteractsWithQueue,Queueable,SerializesModels;
// Our object
private Catalog $o;
@ -26,6 +28,19 @@ class CatalogDelete implements ShouldQueue
$this->o = $o;
}
public function middleware(): array
{
return [new WithoutOverlapping($this->uniqueId())];
}
/**
* Get the unique ID for the job.
*/
public function uniqueId(): string
{
return $this->o::config.'|'.$this->o->id;
}
/**
* Execute the job.
*

View File

@ -32,7 +32,15 @@ class CatalogMove implements ShouldQueue,ShouldBeUnique
public function middleware(): array
{
return [new WithoutOverlapping($this->o::config.'|'.$this->o->id)];
return [new WithoutOverlapping($this->uniqueId())];
}
/**
* Get the unique ID for the job.
*/
public function uniqueId(): string
{
return $this->o::config.'|'.$this->o->id;
}
/**

View File

@ -12,7 +12,7 @@ use Illuminate\Support\Facades\Log;
use App\Models\Abstracted\Catalog;
class CatalogScan implements ShouldQueue, ShouldBeUnique
class CatalogScan implements ShouldQueue,ShouldBeUnique
{
use InteractsWithQueue,Queueable,SerializesModels;