You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
616 B
PHP
27 lines
616 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Helper;
|
|
|
|
use Hyperf\AsyncQueue\Driver\DriverFactory;
|
|
use Hyperf\Utils\ApplicationContext;
|
|
|
|
class Queue
|
|
{
|
|
private static $factory;
|
|
|
|
private static function getFactory()
|
|
{
|
|
if (is_null(self::$factory)) {
|
|
self::$factory = ApplicationContext::getContainer()->get(DriverFactory::class);
|
|
}
|
|
return self::$factory;
|
|
}
|
|
|
|
public static function push($jobClass, $params, int $delay = 0): bool
|
|
{
|
|
$job = new $jobClass($params);
|
|
return self::getFactory()->get($job->getQueueName())->push($job, $delay);
|
|
}
|
|
} |