All checks were successful
star-cloud-deploy-demo / deploy-demo (push) Successful in 36s
47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs\Machine;
|
|
|
|
use App\Services\Machine\MachineService;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class ProcessMachineLog implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
/**
|
|
* @var int
|
|
*/
|
|
protected $machineId;
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $logData;
|
|
|
|
public function __construct(int $machineId, array $logData)
|
|
{
|
|
$this->machineId = $machineId;
|
|
$this->logData = $logData;
|
|
}
|
|
|
|
public function getMachineId(): int
|
|
{
|
|
return $this->machineId;
|
|
}
|
|
|
|
public function handle(MachineService $service): void
|
|
{
|
|
try {
|
|
$service->recordLog($this->machineId, $this->logData);
|
|
} catch (\Exception $e) {
|
|
Log::error("Failed to process machine log for machine {$this->machineId}: " . $e->getMessage());
|
|
}
|
|
}
|
|
}
|