Try to prevent overlaping on job setServiceStat
This commit is contained in:
parent
94aeac4892
commit
c70d8bd376
1 changed files with 9 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ use Illuminate\Bus\Queueable;
|
|||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\Middleware\WithoutOverlapping;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class SetServiceStats implements ShouldQueue
|
||||
|
|
@ -17,6 +18,9 @@ class SetServiceStats implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/** Used to prevent overlaping */
|
||||
private const JOBKEY = 95563222;
|
||||
|
||||
/** @var \App\Models\Service */
|
||||
protected $service;
|
||||
|
||||
|
|
@ -45,4 +49,9 @@ class SetServiceStats implements ShouldQueue
|
|||
$serviceStat->nb_calls += 1;
|
||||
$serviceStat->saveOrFail();
|
||||
}
|
||||
|
||||
public function middleware()
|
||||
{
|
||||
return [(new WithoutOverlapping(self::JOBKEY))->releaseAfter(30)];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue