Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions app/Events/SpeedtestBenchmarkFailed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App\Events;

use App\Models\Result;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class SpeedtestBenchmarkFailed
{
use Dispatchable, InteractsWithSockets, SerializesModels;

/**
* Create a new event instance.
*/
public function __construct(
public Result $result,
) {}
}
20 changes: 20 additions & 0 deletions app/Events/SpeedtestBenchmarkPassed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App\Events;

use App\Models\Result;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class SpeedtestBenchmarkPassed
{
use Dispatchable, InteractsWithSockets, SerializesModels;

/**
* Create a new event instance.
*/
public function __construct(
public Result $result,
) {}
}
6 changes: 6 additions & 0 deletions app/Jobs/Ookla/BenchmarkSpeedtestJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace App\Jobs\Ookla;

use App\Enums\ResultStatus;
use App\Events\SpeedtestBenchmarkFailed;
use App\Events\SpeedtestBenchmarking;
use App\Events\SpeedtestBenchmarkPassed;
use App\Helpers\Benchmark;
use App\Models\Result;
use App\Settings\ThresholdSettings;
Expand Down Expand Up @@ -66,6 +68,10 @@ public function handle(): void
'benchmarks' => $benchmarks,
'healthy' => $this->healthy,
]);

$this->healthy
? SpeedtestBenchmarkPassed::dispatch($this->result)
: SpeedtestBenchmarkFailed::dispatch($this->result);
}

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