1
0
mirror of https://github.com/flarum/core.git synced 2025-10-14 00:15:51 +02:00

Queue support (#1773)

Implementation of clean queue handling, by default sync is used
This commit is contained in:
Daniël Klabbers
2019-08-19 21:44:06 +02:00
committed by GitHub
parent 689d767f82
commit a045f8bef9
6 changed files with 297 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarum\Queue;
use Illuminate\Contracts\Queue\Factory;
class QueueFactory implements Factory
{
/**
* @var callable
*/
private $factory;
/**
* The cached queue instance.
*
* @var \Illuminate\Contracts\Queue\Queue
*/
private $queue;
/**
* QueueFactory constructor.
*
* Expects a callback that will be called to instantiate the queue adapter,
* once requested by the application.
*
* @param callable $factory
*/
public function __construct(callable $factory)
{
$this->factory = $factory;
}
/**
* Resolve a queue connection instance.
*
* @param string $name
* @return \Illuminate\Contracts\Queue\Queue
*/
public function connection($name = null)
{
if (is_null($this->queue)) {
$this->queue = ($this->factory)();
}
return $this->queue;
}
}