From dd5e337ac8490d5e84bdde839deffeb5e14be674 Mon Sep 17 00:00:00 2001 From: Alex Justesen Date: Fri, 27 Dec 2024 14:09:48 -0500 Subject: [PATCH] [Feature] Implement middleware to prevent overlapping execution of RunSpeedtestJob --- app/Jobs/Ookla/RunSpeedtestJob.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/Jobs/Ookla/RunSpeedtestJob.php b/app/Jobs/Ookla/RunSpeedtestJob.php index 3b6ffbaef..f22b5c2dd 100644 --- a/app/Jobs/Ookla/RunSpeedtestJob.php +++ b/app/Jobs/Ookla/RunSpeedtestJob.php @@ -10,6 +10,7 @@ use Illuminate\Bus\Batchable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Queue\Queueable; +use Illuminate\Queue\Middleware\WithoutOverlapping; use Illuminate\Support\Arr; use Symfony\Component\Process\Exception\ProcessFailedException; use Symfony\Component\Process\Process; @@ -32,6 +33,16 @@ public function __construct( public Result $result, ) {} + /** + * Get the middleware the job should pass through. + * + * @return array + */ + public function middleware(): array + { + return [new WithoutOverlapping('run-speedtest')]; + } + /** * Execute the job. */