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:
57
src/Queue/QueueFactory.php
Normal file
57
src/Queue/QueueFactory.php
Normal 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user