You are here

function advancedqueue_example_worker in Advanced Queue 7

Advanced queue worker; Process a queue item.

Parameters

$item: The item object to process.

$end_time: (Optional) The time this process should end.

Return value

Boolean indicating if the process succeeded, or an array with "status" and "result" keys.

2 string references to 'advancedqueue_example_worker'
advancedqueue_example_advanced_queue_info in advancedqueue_example/advancedqueue_example.module
Implements hook_advanced_queue_info().
hook_advanced_queue_info in ./advancedqueue.api.php
Declare queue(s) that will be run by Advanced queue.

File

advancedqueue_example/advancedqueue_example.module, line 40
Example module for Advanced Queues module.

Code

function advancedqueue_example_worker($item, $end_time = FALSE) {
  $data = $item->data;
  $params = array(
    '@id' => $item->item_id,
    '@uid' => $data['uid'],
    '@time' => date('r', $data['timestamp']),
  );
  advancedqueue_log_message(format_string('The "worker" is now processing a example task number @id for user ID @uid created at @time.', $params));

  // For example purposes we will return an array with detailed message
  // for odd item IDs, and boolean for even ones.
  if ($item->item_id % 2) {
    return TRUE;
  }
  return array(
    'status' => ADVANCEDQUEUE_STATUS_SUCCESS,
    'result' => 'Processed ' . $item->item_id,
  );
}