Class Ibuildings_Gearman_Model_Queue

Description

Ibuildings Gearman Magento Model Observer

Located in /Queue.php (line 17)

Mage_Core_Model_Abstract
   |
   --Ibuildings_Gearman_Model_Queue
Method Summary
Ibuildings_Gearman_Model_Queue __construct ()
array|null blockingCall ( $task, [ $timeout = null])
null|string checkJobStatus ( $jobId, string $id)
boolean checkTaskComplete ( $jobId, string $id)
string|false dispatchTask (array $task)
GearmanClient|Net_Gearman_Client getGearmanClient ()
string getJobStatus ( $status)
void setGearmanClient ([array $opts = null])
Methods
Constructor __construct (line 30)

Just calls setGearmanClient() for default instantiation

Ibuildings_Gearman_Model_Queue __construct ()
blockingCall (line 200)

Calls a Gearman task and waits for it's return value

  1.  $ret $queue->blockingCall($task);

  • return: The results from the task
  • access: public
array|null blockingCall ( $task, [ $timeout = null])
  • $task
  • $timeout
checkJobStatus (line 153)

Check the status of a previously submitted job

  1.  while (($status $queue->checkJobStatus($id)) !== 'done'{
  2.      echo "$status% complete\n";
  3.      sleep(1);
  4.  }

  • access: public
null|string checkJobStatus ( $jobId, string $id)
  • string $id: The unique Gearman job ID
  • $jobId
checkTaskComplete (line 130)

Check whether a previously submitted job has completed

  1.  if ($queue->checkTaskComplete($id)) {
  2.      // work has been done
  3.  }

  • return: Whether task is complete or not
  • access: public
boolean checkTaskComplete ( $jobId, string $id)
  • string $id: The unique Gearman job ID
  • $jobId
dispatchTask (line 98)

Send the job to the queue specified

  1.  $queue Mage::getModel('gearman/queue');
  2.  $id $queue->dispatchTask($task);

  • return: The ID for the submitted task if the Gearman extension is used
  • access: public
string|false dispatchTask (array $task)
  • array $task: Array containing the 'queue' name and the task
getGearmanClient (line 83)

Returns the current client object used for dispatching messages

You should not have to use this method, and it is meant for testing

  • return: The client being used
  • access: public
GearmanClient|Net_Gearman_Client getGearmanClient ()
getJobStatus (line 172)

Returns the current job status

Turns the status array from Gearman into a meaningful status to report back to the client

  • return: The current status
  • access: public
string getJobStatus ( $status)
  • $status
setGearmanClient (line 49)

Sets the Gearman object according to config options

Reads the server details from config and creates the GearmanClient object and connects to the queue server. There is an optional 'type' key, which can be used to force the type of client used. This was introduced for testing purposes and should be used with caution as Net_Gearman & Gearman extension queues cannot be used interchangeably.

Also, I have not seen this documented anywhere, but it seems that the addServer/s() method does not perform host lookup and must have a dotted-quad IP sent for it to be able to connect to the job server.

  • access: public
void setGearmanClient ([array $opts = null])
  • array $opts: Configuration options

Documentation generated on Wed, 01 Dec 2010 13:24:05 +0000 by phpDocumentor 1.4.3