lliure/processqueue

基于 lliure 模型的 PHP 任务调度处理包

v1.3.1 2022-08-12 15:01 UTC

This package is auto-updated.

Last update: 2024-09-12 19:54:13 UTC


README

使用 lliure-core 模型简单地管理进程队列的类

如何创建模型?

namespace \Models;

use ProcessQueue\ProcessQueueModel;

class Queue extends ProcessQueueModel
{
    protected static array $fields = ['id', 'attempts']; // define your fields, is required to have id and attempts fields
    protected static ?string $table = 'queue'; // define your table
    protected static $attempts = 5; // opcional, set maximum attempts 
}

如何使用?

$processes = Queue::getProcess(); //capturing available processes

foreach ($processes as $process){
    $process->start(); // starting the process

    if($myteste){
        $process->confirmProcess(); //confirming a process
    } else {
        $process->errorProcess('Erro of process'); //reporting an error
    }
}