Skip to content

Commit 071cea4

Browse files
authored
[Feature] Add events for speedtest benchmark failed and passed (alexjustesen#2106)
1 parent 5e19a2b commit 071cea4

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace App\Events;
4+
5+
use App\Models\Result;
6+
use Illuminate\Broadcasting\InteractsWithSockets;
7+
use Illuminate\Foundation\Events\Dispatchable;
8+
use Illuminate\Queue\SerializesModels;
9+
10+
class SpeedtestBenchmarkFailed
11+
{
12+
use Dispatchable, InteractsWithSockets, SerializesModels;
13+
14+
/**
15+
* Create a new event instance.
16+
*/
17+
public function __construct(
18+
public Result $result,
19+
) {}
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace App\Events;
4+
5+
use App\Models\Result;
6+
use Illuminate\Broadcasting\InteractsWithSockets;
7+
use Illuminate\Foundation\Events\Dispatchable;
8+
use Illuminate\Queue\SerializesModels;
9+
10+
class SpeedtestBenchmarkPassed
11+
{
12+
use Dispatchable, InteractsWithSockets, SerializesModels;
13+
14+
/**
15+
* Create a new event instance.
16+
*/
17+
public function __construct(
18+
public Result $result,
19+
) {}
20+
}

app/Jobs/Ookla/BenchmarkSpeedtestJob.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
namespace App\Jobs\Ookla;
44

55
use App\Enums\ResultStatus;
6+
use App\Events\SpeedtestBenchmarkFailed;
67
use App\Events\SpeedtestBenchmarking;
8+
use App\Events\SpeedtestBenchmarkPassed;
79
use App\Helpers\Benchmark;
810
use App\Models\Result;
911
use App\Settings\ThresholdSettings;
@@ -66,6 +68,10 @@ public function handle(): void
6668
'benchmarks' => $benchmarks,
6769
'healthy' => $this->healthy,
6870
]);
71+
72+
$this->healthy
73+
? SpeedtestBenchmarkPassed::dispatch($this->result)
74+
: SpeedtestBenchmarkFailed::dispatch($this->result);
6975
}
7076

7177
private function benchmark(Result $result, ThresholdSettings $settings): array

0 commit comments

Comments
 (0)