/** * Get the job status for a given job * * @param Lilmuckers_Queue_Model_Queue_Task $task The task to map data for * * @return array */ protected function _getMappedTaskData(Lilmuckers_Queue_Model_Queue_Task $task) { //get the pheanstalk job $_job = $task->getJob(); try { //get the data on the job $_status = $this->getConnection()->statsJob($_job); } catch (Pheanstalk_Exception_ServerException $e) { //no job found, so return an empty dataset return array(); } return $this->_mapJobStatToTaskInfo($_status); }
/** * Test worker - just flags the task as a success and ends * * @param Lilmuckers_Queue_Model_Queue_Task $task Task handler object * * @return Lilmuckers_Queue_Model_Worker */ public function test(Lilmuckers_Queue_Model_Queue_Task $task) { $task->success(); return $this; }
/** * Get the job status for a given job * * @param Lilmuckers_Queue_Model_Queue_Task $task The task to map data for * * @return array */ protected function _getMappedTaskData(Lilmuckers_Queue_Model_Queue_Task $task) { //get the pheanstalk job $_job = $task->getJob(); return $this->_mapJobStatToTaskInfo($_job); }
/** * Run the specific task * * @param Lilmuckers_Queue_Model_Queue_Task $task The task to run * * @return Lilmuckers_Queue_Model_Queue_Abstract * * @throws Lilmuckers_Queue_Model_Queue_Db_Exception */ public function runTask(Lilmuckers_Queue_Model_Queue_Task $task) { //run the task and get the result status switch ($task->run()) { case Lilmuckers_Queue_Model_Queue_Task::TASK_CONFIG_ERROR: case Lilmuckers_Queue_Model_Queue_Task::TASK_ERROR: case Lilmuckers_Queue_Model_Queue_Task::TASK_HOLD: //if it's a configuration error - bury it $this->hold($task); break; case Lilmuckers_Queue_Model_Queue_Task::TASK_DATABASE_ERROR: //flag this for a retry, and then throw a DB error //for the queue watcher script to catch $this->retry($task); throw new Lilmuckers_Queue_Model_Queue_Db_Exception('Unspecified database connection error'); break; case Lilmuckers_Queue_Model_Queue_Task::TASK_RETRY: //this has been flagged for a retry $this->retry($task); break; case Lilmuckers_Queue_Model_Queue_Task::TASK_SUCCESS: default: //for success and default behavour - remove from queue $this->remove($task); break; } return $this; }