You are here

function computing_finish in Drupal Computing 7.2

When agent finishes a computational task, call this function to persist results back to Drupal.

Parameters

$id:

$status:

$message:

mixed $output: Results in object or array, will be encoded in json before persistence.

array $options:

Return value

bool

1 string reference to 'computing_finish'
computing_services_resources in ./computing.services.inc
Implements hook_services_resources().

File

./computing.module, line 434

Code

function computing_finish($id, $status, $message, $output, $options = array()) {

  // check computing record status. If it's not set as Running from computing_claim(), then abort.
  $record = computing_load($id);
  if (!$record || $record->status != 'RUN') {
    return FALSE;
  }
  $record->status = $status;
  $record->message = $message;
  $record->output = $output;
  if (!empty($options) && is_array($options)) {
    foreach ($options as $field_name => $field_value) {
      _computing_set_field($record, $field_name, $field_value);
    }
  }
  $return = computing_update($record);
  if ($return) {

    // needs to reload the record, because input/output would have been encoded inside of computing_update().
    rules_invoke_event('computing_event_finished', computing_load($id));
  }
  return $return;
}