function hosting_get_queues in Hosting 6.2
Same name and namespace in other branches
- 5 hosting.queues.inc \hosting_get_queues()
- 7.4 hosting.queues.inc \hosting_get_queues()
- 7.3 hosting.queues.inc \hosting_get_queues()
Retrieve a list of queues that need to be dispatched
Generate a list of queues, and the frequency / amount of items that need to be processed for each of them.
Related topics
10 calls to hosting_get_queues()
- drush_hosting_dispatch in ./
dispatch.hosting.inc - Main queue processing drush command for hostmaster.
- hosting_drush_command in ./
hosting.drush.inc - Implementation of hook_drush_command().
- hosting_queues in ./
hosting.module - List queues or tasks in a queue if a key is provided.
- hosting_queues_configure in ./
hosting.module - Form to configure the frequency of queue execution.
- hosting_queues_configure_submit in ./
hosting.module - Submit callback for the the queue execution frequency form.
1 string reference to 'hosting_get_queues'
- hosting_drush_command in ./
hosting.drush.inc - Implementation of hook_drush_command().
File
- ./
hosting.queues.inc, line 56 - This file defines an API for defining new queues.
Code
function hosting_get_queues($refresh = FALSE) {
static $cache = NULL;
if (is_null($cache) || $refresh) {
$cache = array();
$defaults = array(
'type' => 'serial',
'max_threads' => 6,
'threshold' => '100',
'min_threads' => 1,
'timeout' => strtotime("10 minutes", 0),
'frequency' => strtotime("5 minutes", 0),
'items' => 5,
'enabled' => TRUE,
'singular' => t('item'),
'plural' => t('items'),
);
$queues = module_invoke_all("hosting_queues");
foreach ($queues as $key => $queue) {
$queue = array_merge($defaults, $queue);
// Configurable settings.
$configured = array(
'frequency' => variable_get('hosting_queue_' . $key . '_frequency', $queue['frequency']),
'items' => variable_get('hosting_queue_' . $key . '_items', $queue['items']),
'enabled' => variable_get('hosting_queue_' . $key . '_enabled', $queue['enabled']),
'last_run' => variable_get('hosting_queue_' . $key . '_last_run', FALSE),
'running' => variable_get('hosting_queue_' . $key . '_running', FALSE),
'interval' => variable_get('hosting_queue_' . $key . '_interval', FALSE),
);
$queue = array_merge($queue, $configured);
if ($queue['type'] == 'batch') {
$threads = $queue['total_items'] / $queue['threshold'];
if ($threads <= $queue['min_threads']) {
$threads = $queue['min_threads'];
}
elseif ($thread > $queue['max_threads']) {
$threads = $queue['max_threads'];
}
$queue['calc_threads'] = $threads;
$queue['calc_frequency'] = ceil($queue['frequency'] / $threads);
$queue['calc_items'] = ceil($queue['total_items'] / $threads);
}
else {
$queue['calc_frequency'] = $queue['frequency'];
$queue['calc_items'] = $queue['items'];
}
$queue['last'] = variable_get('hosting_queue_' . $key . '_last_run', 0);
$queue['running'] = variable_get('hosting_queue_' . $key . '_running', 0);
$queues[$key] = $queue;
}
$cache = $queues;
}
return $cache;
}