Files
trackbugs/app/Jobs/ProcessEventJob.php
T
2026-03-19 19:32:46 +02:00

41 lines
1.0 KiB
PHP

<?php
namespace App\Jobs;
use App\Models\Project;
use App\Services\EventProcessor;
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 ProcessEventJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public int $tries = 3;
public int $backoff = 5;
public function __construct(
public Project $project,
public array $rawPayload,
) {}
public function handle(EventProcessor $processor): void
{
$processor->process($this->project, $this->rawPayload);
}
public function failed(\Throwable $exception): void
{
Log::error('Failed to process event', [
'project_id' => $this->project->id,
'event_id' => $this->rawPayload['event_id'] ?? 'unknown',
'error' => $exception->getMessage(),
]);
}
}