Laravel app with a cost-tracked Runware.ai integration (image, video, text generation), a hard monthly EUR budget cap with live USD/EUR FX conversion, and a locally-maintained model/pricing table since Runware's model-search API doesn't expose pricing.
35 lines
934 B
PHP
35 lines
934 B
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Models\Generation;
|
|
use App\Services\Runware\GenerationService;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Throwable;
|
|
|
|
class GenerateVideoJob implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
// Video submission + polling can legitimately take minutes.
|
|
public int $timeout = 900;
|
|
|
|
public int $tries = 1;
|
|
|
|
public function __construct(public Generation $generation) {}
|
|
|
|
public function handle(GenerationService $generations): void
|
|
{
|
|
try {
|
|
$generations->processVideo($this->generation);
|
|
} catch (Throwable $e) {
|
|
$this->generation->update(['status' => 'failed', 'error' => $e->getMessage()]);
|
|
throw $e;
|
|
}
|
|
}
|
|
}
|