mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 18:51:41 +09:00
169 lines
2.9 KiB
PHP
169 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace Rhymix\Framework\Drivers\Queue;
|
|
|
|
use Rhymix\Framework\Drivers\QueueInterface;
|
|
|
|
/**
|
|
* The Dummy queue driver.
|
|
*/
|
|
class Dummy implements QueueInterface
|
|
{
|
|
/**
|
|
* Dummy queue for testing.
|
|
*/
|
|
protected $_dummy_queue;
|
|
|
|
/**
|
|
* Create a new instance of the current Queue driver, using the given settings.
|
|
*
|
|
* @param array $config
|
|
* @return QueueInterface
|
|
*/
|
|
public static function getInstance(array $config): QueueInterface
|
|
{
|
|
return new self($config);
|
|
}
|
|
|
|
/**
|
|
* Get the human-readable name of this Queue driver.
|
|
*
|
|
* @return string
|
|
*/
|
|
public static function getName(): string
|
|
{
|
|
return 'Dummy';
|
|
}
|
|
|
|
/**
|
|
* Get the list of configuration fields required by this Queue driver.
|
|
*
|
|
* @return array
|
|
*/
|
|
public static function getRequiredConfig(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* Get the list of configuration fields optionally used by this Queue driver.
|
|
*
|
|
* @return array
|
|
*/
|
|
public static function getOptionalConfig(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* Check if this driver is supported on this server.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public static function isSupported(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Validate driver configuration.
|
|
*
|
|
* @param mixed $config
|
|
* @return bool
|
|
*/
|
|
public static function validateConfig($config): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Constructor.
|
|
*
|
|
* @param array $config
|
|
*/
|
|
public function __construct(array $config)
|
|
{
|
|
|
|
}
|
|
|
|
/**
|
|
* Add a task.
|
|
*
|
|
* @param string $handler
|
|
* @param ?object $args
|
|
* @param ?object $options
|
|
* @return int
|
|
*/
|
|
public function addTask(string $handler, ?object $args = null, ?object $options = null): int
|
|
{
|
|
$this->_dummy_queue = (object)[
|
|
'handler' => $handler,
|
|
'args' => $args,
|
|
'options' => $options,
|
|
];
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* Add a task to be executed at a specific time.
|
|
*
|
|
* @param int $time
|
|
* @param string $handler
|
|
* @param ?object $args
|
|
* @param ?object $options
|
|
* @return int
|
|
*/
|
|
public function addTaskAt(int $time, string $handler, ?object $args = null, ?object $options = null): int
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
/**
|
|
* Add a task to be executed at an interval.
|
|
*
|
|
* @param string $interval
|
|
* @param string $handler
|
|
* @param ?object $args
|
|
* @param ?object $options
|
|
* @return int
|
|
*/
|
|
public function addTaskAtInterval(string $interval, string $handler, ?object $args = null, ?object $options = null): int
|
|
{
|
|
return 2;
|
|
}
|
|
|
|
/**
|
|
* Get the next task from the queue.
|
|
*
|
|
* @param int $blocking
|
|
* @return ?object
|
|
*/
|
|
public function getNextTask(int $blocking = 0): ?object
|
|
{
|
|
$result = $this->_dummy_queue;
|
|
$this->_dummy_queue = null;
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* Get scheduled tasks.
|
|
*
|
|
* @param string $type
|
|
* @return array
|
|
*/
|
|
public function getScheduledTasks(string $type): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* Update the last executed timestamp of a scheduled task.
|
|
*
|
|
* @param object $task
|
|
* @return void
|
|
*/
|
|
public function updateLastRunTimestamp(object $task): void
|
|
{
|
|
|
|
}
|
|
}
|