-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample2.php
More file actions
29 lines (24 loc) · 806 Bytes
/
sample2.php
File metadata and controls
29 lines (24 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
namespace app\services\kafka\handlers;
use app\models\Bot;
use app\services\BotService;
use app\services\kafka\events\BwBotContainerStoppedEvent;
use app\services\kafka\events\LkStopBotContainerEvent;
use app\services\KafkaService;
class LkStopBotContainerEventHandler
{
public function handle(LkStopBotContainerEvent $event): void
{
$bot = Bot::findOne($event->getBotId());
$bs = new BotService();
if ($bs->canStopContainer($bot)) {
$result = $bs->stopContainer($bot);
$status = "stopped";
} else {
$status = "failed";
}
$ks = new KafkaService();
$event = new BwBotContainerStoppedEvent($event->getBotId(), $status);
$ks->produce("event_bus", $event->getPayload());
}
}