83a6b9af293f98b5fe63d75cede56185996c0a2e
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
29 * A queue is an object (usually backed by some persistent data store)
30 * which stores a list of tasks or messages for use by other processes.
32 * This would ideally be an interface, but it's handy to specify the
33 * "function __construct()" and the "$name" handling
35 * Note: This interface closely parallels the DrupalQueueInterface.
37 abstract class CRM_Queue_Queue
{
45 * Create a reference to queue. After constructing the queue, one should
46 * usually call createQueue (if it's a new queue) or loadQueue (if it's
47 * known to be an existing queue).
49 * @param array $queueSpec
51 * - type: string, required, e.g. "interactive", "immediate", "stomp",
53 * - name: string, required, e.g. "upgrade-tasks"
54 * - reset: bool, optional; if a queue is found, then it should be
55 * flushed; default to TRUE
56 * - (additional keys depending on the queue provider).
58 public function __construct($queueSpec) {
59 $this->_name
= $queueSpec['name'];
63 * Determine the string name of this queue.
67 public function getName() {
72 * Perform any registation or resource-allocation for a new queue
74 public abstract function createQueue();
77 * Perform any loading or pre-fetch for an existing queue.
79 public abstract function loadQueue();
82 * Release any resources claimed by the queue (memory, DB rows, etc)
84 public abstract function deleteQueue();
87 * Check if the queue exists.
91 public abstract function existsQueue();
94 * Add a new item to the queue.
97 * Serializable PHP object or array.
98 * @param array $options
99 * Queue-dependent options; for example, if this is a
100 * priority-queue, then $options might specify the item's priority.
102 public abstract function createItem($data, $options = array());
105 * Determine number of items remaining in the queue.
109 public abstract function numberOfItems();
114 * @param int $lease_time
118 * with key 'data' that matches the inputted data
120 public abstract function claimItem($lease_time = 3600);
123 * Get the next item, even if there's an active lease
125 * @param int $lease_time
129 * with key 'data' that matches the inputted data
131 public abstract function stealItem($lease_time = 3600);
134 * Remove an item from the queue.
136 * @param object $item
137 * The item returned by claimItem.
139 public abstract function deleteItem($item);
142 * Return an item that could not be processed.
144 * @param object $item
145 * The item returned by claimItem.
147 public abstract function releaseItem($item);