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\taoTaskQueue\model; |
23 | |
24 | use oat\tao\model\taskQueue\Queue\TaskSelector\SelectorStrategyInterface; |
25 | use oat\taoTaskQueue\model\Task\CallbackTaskInterface; |
26 | use oat\taoTaskQueue\model\Task\TaskInterface; |
27 | use Psr\Log\LoggerAwareInterface; |
28 | |
29 | /** |
30 | * Interface QueueDispatcherInterface |
31 | * |
32 | * @deprecated Use \oat\tao\model\taskQueue\QueueDispatcherInterface |
33 | * |
34 | * @author Gyula Szucs <gyula@taotesting.com> |
35 | */ |
36 | interface QueueDispatcherInterface extends \Countable, LoggerAwareInterface |
37 | { |
38 | /** @deprecated */ |
39 | public const SERVICE_ID = 'taoTaskQueue/taskQueue'; |
40 | |
41 | public const FILE_SYSTEM_ID = 'taskQueueStorage'; |
42 | |
43 | /** |
44 | * Array of queues |
45 | */ |
46 | public const OPTION_QUEUES = 'queues'; |
47 | |
48 | /** |
49 | * Name of the default queue. Task without specified queue will be published here. |
50 | */ |
51 | public const OPTION_DEFAULT_QUEUE = 'default_queue'; |
52 | |
53 | /** |
54 | * An array of tasks names with the specified queue where the tasks needs to be published to. |
55 | */ |
56 | public const OPTION_TASK_TO_QUEUE_ASSOCIATIONS = 'task_to_queue_associations'; |
57 | |
58 | public const OPTION_TASK_LOG = 'task_log'; |
59 | |
60 | public const OPTION_TASK_SELECTOR_STRATEGY = 'task_selector_strategy'; |
61 | |
62 | public const QUEUE_PREFIX = 'TQ'; |
63 | |
64 | /** |
65 | * Add new Queue. |
66 | * |
67 | * @param QueueInterface $queue |
68 | * @return QueueDispatcherInterface |
69 | */ |
70 | public function addQueue(QueueInterface $queue); |
71 | |
72 | /** |
73 | * @param QueueInterface[] $queues |
74 | * @return QueueDispatcherInterface |
75 | */ |
76 | public function setQueues(array $queues); |
77 | |
78 | /** |
79 | * @param string $queueName |
80 | * @return QueueInterface |
81 | */ |
82 | public function getQueue($queueName); |
83 | |
84 | /** |
85 | * @return QueueInterface[] |
86 | */ |
87 | public function getQueues(); |
88 | |
89 | /** |
90 | * Get the names of the registered queues. |
91 | * |
92 | * @return array |
93 | */ |
94 | public function getQueueNames(); |
95 | |
96 | /** |
97 | * Has the given queue/queue name already been set? |
98 | * |
99 | * @param string $queueName |
100 | * @return bool |
101 | */ |
102 | public function hasQueue($queueName); |
103 | |
104 | /** |
105 | * Get the default queue. |
106 | * |
107 | * @return QueueInterface |
108 | */ |
109 | public function getDefaultQueue(); |
110 | |
111 | /** |
112 | * Get a queue randomly using weight. |
113 | * |
114 | * @deprecated |
115 | * @return QueueInterface |
116 | */ |
117 | public function getQueueByWeight(); |
118 | |
119 | /** |
120 | * Link a task to a queue. |
121 | * |
122 | * @param string|object $taskName |
123 | * @param string $queueName |
124 | * @return QueueDispatcherInterface |
125 | */ |
126 | public function linkTaskToQueue($taskName, $queueName); |
127 | |
128 | /** |
129 | * Get the linked tasks. |
130 | * |
131 | * @return array |
132 | */ |
133 | public function getLinkedTasks(); |
134 | |
135 | /** |
136 | * Initialize queues. |
137 | * |
138 | * @return void |
139 | */ |
140 | public function initialize(); |
141 | |
142 | /** |
143 | * Create a task to be managed by the queue from any callable |
144 | * |
145 | * @param callable $callable |
146 | * @param array $parameters |
147 | * @param null|string $label Label for the task |
148 | * @param null|TaskInterface $parent |
149 | * @param boolean $masterStatus |
150 | * @return CallbackTaskInterface |
151 | */ |
152 | public function createTask( |
153 | callable $callable, |
154 | array $parameters = [], |
155 | $label = null, |
156 | TaskInterface $parent = null, |
157 | $masterStatus = false |
158 | ); |
159 | |
160 | /** |
161 | * Publish a task to a queue. |
162 | * |
163 | * @param TaskInterface $task |
164 | * @param null|string $label Label for the task |
165 | * @return bool Is the task successfully enqueued? |
166 | */ |
167 | public function enqueue(TaskInterface $task, $label = null); |
168 | |
169 | /** |
170 | * Receive a task from a specified queue or from a queue selected by a predefined strategy |
171 | * |
172 | * @param null|string $queueName |
173 | * @return null|TaskInterface |
174 | */ |
175 | public function dequeue($queueName = null); |
176 | |
177 | /** |
178 | * Acknowledge that the task has been received and consumed. |
179 | * |
180 | * @param TaskInterface $task |
181 | */ |
182 | public function acknowledge(TaskInterface $task); |
183 | |
184 | /** |
185 | * Are all queues a sync one? |
186 | * |
187 | * @return bool |
188 | */ |
189 | public function isSync(); |
190 | |
191 | /** |
192 | * Get resource from rdf storage which represents task in the task queue by linked resource |
193 | * Returns null if there is no task linked to given resource |
194 | * |
195 | * It will be deprecated once we have the general GUI for displaying different info of a task for the user. |
196 | * |
197 | * @param \core_kernel_classes_Resource $resource |
198 | * @return null|\core_kernel_classes_Resource |
199 | */ |
200 | public function getTaskResource(\core_kernel_classes_Resource $resource); |
201 | |
202 | /** |
203 | * Get report by a linked resource. |
204 | * |
205 | * It will be deprecated once we have the general GUI for displaying different info of a task for the user. |
206 | * |
207 | * @param \core_kernel_classes_Resource $resource |
208 | * @return \common_report_Report |
209 | */ |
210 | public function getReportByLinkedResource(\core_kernel_classes_Resource $resource); |
211 | |
212 | /** |
213 | * Create task resource in the rdf storage and link placeholder resource to it. |
214 | * |
215 | * It will be deprecated once we have the general GUI for displaying different info of a task for the user. |
216 | * |
217 | * @param TaskInterface $task |
218 | * @param \core_kernel_classes_Resource|null $resource Placeholder resource linked to the task |
219 | */ |
220 | public function linkTaskToResource(TaskInterface $task, \core_kernel_classes_Resource $resource = null); |
221 | |
222 | /** |
223 | * @param SelectorStrategyInterface $selectorStrategy |
224 | * @return QueueDispatcherInterface |
225 | */ |
226 | public function setTaskSelector(SelectorStrategyInterface $selectorStrategy); |
227 | |
228 | /** |
229 | * Seconds for the worker to wait if there is no task. |
230 | * |
231 | * @return int |
232 | */ |
233 | public function getWaitTime(); |
234 | } |