DLight\Application\Drive\Queue\DbQueue
Mô tả: queue driver lưu job trong DB table dlight_queue_jobs.
Hỗ trợ install table (MySQL/SQLite), push job với payload JSON, pop/reserve theo transaction,
process 1 job, tracking progress (0..100) và status.
Public API
__construct(?DLight\Application\DB $db = null)install(): voidpush(string $job, array $data = [], ?int $availableAt = null): voidpop(string $job): arrayprocess(string $job, callable|string|null $handler = null): ?arraygetQueue(string $job): arraygetQueueSize(string $job): intgetQueueStatus(string $job): stringgetQueueProgress(string $job): floatsetProgress(int $id, float $progress): void
Job handler format
- Class:
App\Jobs\ExampleJob::class→ nếu object callable thì gọi$instance($data, $context, $queue), nếu cóhandle()thì gọihandle(). - Class@method:
App\Jobs\ExampleJob@handle→ gọi method tương ứng.
Demo
use DLight\Application\Drive\Queue\DbQueue;
$q = new DbQueue();
$q->install();
$q->push(App\\Jobs\\ExampleJob::class, ['id' => 1]);
// Process 1 item
$item = $q->process(App\\Jobs\\ExampleJob::class);
// Inspect queue
$all = $q->getQueue(App\\Jobs\\ExampleJob::class);
$progress = $q->getQueueProgress(App\\Jobs\\ExampleJob::class);