Skip to content

Commit 829d7c0

Browse files
authored
Refactor data integration event handling (alexjustesen#2436)
Co-authored-by: Alex Justesen <[email protected]>
1 parent 7ebd8f9 commit 829d7c0

File tree

2 files changed

+42
-52
lines changed

2 files changed

+42
-52
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace App\Listeners;
4+
5+
use App\Events\SpeedtestCompleted;
6+
use App\Events\SpeedtestFailed;
7+
use App\Jobs\Influxdb\v2\WriteResult;
8+
use App\Settings\DataIntegrationSettings;
9+
use Illuminate\Events\Dispatcher;
10+
11+
class DataIntegrationSubscriber
12+
{
13+
/**
14+
* Create the event listener.
15+
*/
16+
public function __construct(
17+
public DataIntegrationSettings $settings,
18+
) {}
19+
20+
/**
21+
* Handle the event.
22+
*/
23+
public function handle(object $event): void
24+
{
25+
if ($this->settings->influxdb_v2_enabled) {
26+
WriteResult::dispatch($event->result);
27+
}
28+
}
29+
30+
/**
31+
* Register the listeners for the subscriber.
32+
*
33+
* @return array<string, string>
34+
*/
35+
public function subscribe(Dispatcher $events): array
36+
{
37+
return [
38+
SpeedtestCompleted::class => 'handleSpeedtestCompleted',
39+
SpeedtestFailed::class => 'handleSpeedtestFailed',
40+
];
41+
}
42+
}

app/Listeners/SpeedtestEventSubscriber.php

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)