Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2017 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\tao\model\taskQueue; |
| 23 | |
| 24 | use oat\tao\model\taskQueue\Queue\TaskSelector\SelectorStrategyInterface; |
| 25 | use oat\tao\model\taskQueue\Task\CallbackTaskInterface; |
| 26 | use oat\tao\model\taskQueue\Task\TaskInterface; |
| 27 | use Psr\Log\LoggerAwareInterface; |
| 28 | |
| 29 | /** |
| 30 | * @author Gyula Szucs <gyula@taotesting.com> |
| 31 | */ |
| 32 | interface QueueDispatcherInterface extends QueuerInterface, LoggerAwareInterface |
| 33 | { |
| 34 | public const SERVICE_ID = 'tao/taskQueue'; |
| 35 | |
| 36 | public const FILE_SYSTEM_ID = 'taskQueueStorage'; |
| 37 | |
| 38 | /** |
| 39 | * Array of queues |
| 40 | */ |
| 41 | public const OPTION_QUEUES = 'queues'; |
| 42 | |
| 43 | /** |
| 44 | * Name of the default queue. Task without specified queue will be published here. |
| 45 | */ |
| 46 | public const OPTION_DEFAULT_QUEUE = 'default_queue'; |
| 47 | |
| 48 | /** |
| 49 | * An array of tasks names with the specified queue where the tasks needs to be published to. |
| 50 | */ |
| 51 | public const OPTION_TASK_TO_QUEUE_ASSOCIATIONS = 'task_to_queue_associations'; |
| 52 | |
| 53 | public const OPTION_TASK_LOG = 'task_log'; |
| 54 | |
| 55 | public const OPTION_TASK_SELECTOR_STRATEGY = 'task_selector_strategy'; |
| 56 | |
| 57 | public const QUEUE_PREFIX = 'TQ'; |
| 58 | |
| 59 | /** |
| 60 | * Add new Queue. |
| 61 | * |
| 62 | * @param QueueInterface $queue |
| 63 | * @return QueueDispatcherInterface |
| 64 | */ |
| 65 | public function addQueue(QueueInterface $queue); |
| 66 | |
| 67 | /** |
| 68 | * @param QueueInterface[] $queues |
| 69 | * @return QueueDispatcherInterface |
| 70 | */ |
| 71 | public function setQueues(array $queues); |
| 72 | |
| 73 | /** |
| 74 | * @param string $queueName |
| 75 | * @return QueueInterface |
| 76 | */ |
| 77 | public function getQueue($queueName); |
| 78 | |
| 79 | /** |
| 80 | * @return QueueInterface[] |
| 81 | */ |
| 82 | public function getQueues(); |
| 83 | |
| 84 | /** |
| 85 | * Get the names of the registered queues. |
| 86 | * |
| 87 | * @return array |
| 88 | */ |
| 89 | public function getQueueNames(); |
| 90 | |
| 91 | /** |
| 92 | * Has the given queue/queue name already been set? |
| 93 | * |
| 94 | * @param string $queueName |
| 95 | * @return bool |
| 96 | */ |
| 97 | public function hasQueue($queueName); |
| 98 | |
| 99 | /** |
| 100 | * Get the default queue. |
| 101 | * |
| 102 | * @return QueueInterface |
| 103 | */ |
| 104 | public function getDefaultQueue(); |
| 105 | |
| 106 | /** |
| 107 | * Link a task to a queue. |
| 108 | * |
| 109 | * @param string|object $taskName |
| 110 | * @param string $queueName |
| 111 | * @return QueueDispatcherInterface |
| 112 | */ |
| 113 | public function linkTaskToQueue($taskName, $queueName); |
| 114 | |
| 115 | /** |
| 116 | * Get the linked tasks. |
| 117 | * |
| 118 | * @return array |
| 119 | */ |
| 120 | public function getLinkedTasks(); |
| 121 | |
| 122 | /** |
| 123 | * Initialize queues. |
| 124 | * |
| 125 | * @return void |
| 126 | */ |
| 127 | public function initialize(); |
| 128 | |
| 129 | /** |
| 130 | * Create a task to be managed by the queue from any callable |
| 131 | * |
| 132 | * @param callable $callable |
| 133 | * @param array $parameters |
| 134 | * @param null|string $label Label for the task |
| 135 | * @param null|TaskInterface $parent |
| 136 | * @param boolean $masterStatus |
| 137 | * @return CallbackTaskInterface |
| 138 | */ |
| 139 | public function createTask( |
| 140 | callable $callable, |
| 141 | array $parameters = [], |
| 142 | $label = null, |
| 143 | TaskInterface $parent = null, |
| 144 | $masterStatus = false |
| 145 | ); |
| 146 | |
| 147 | /** |
| 148 | * Are all queues a sync one? |
| 149 | * |
| 150 | * @return bool |
| 151 | */ |
| 152 | public function isSync(); |
| 153 | |
| 154 | /** |
| 155 | * @param SelectorStrategyInterface $selectorStrategy |
| 156 | * @return QueueDispatcherInterface |
| 157 | */ |
| 158 | public function setTaskSelector(SelectorStrategyInterface $selectorStrategy); |
| 159 | |
| 160 | /** |
| 161 | * Seconds for the worker to wait if there is no task. |
| 162 | * |
| 163 | * @return int |
| 164 | */ |
| 165 | public function getWaitTime(); |
| 166 | } |