public function testQueueConfigParse()
 {
     $config = new WorkerConfig();
     $data = array('worker' => array('jobs_process' => 4, 'mean_runtime' => 60 * 60 * 1, 'cron_script' => '* * * * *', 'job_lock_timeout' => 60 * 60 * 4, 'worker_name' => 'bobemail'));
     $config->parse($data);
     $this->assertEquals($data['worker']['jobs_process'], $config->getJobsToProcess());
     $this->assertEquals($data['worker']['mean_runtime'], $config->getMeanRuntime());
     $this->assertEquals($data['worker']['cron_script'], $config->getCronDefinition());
     $this->assertEquals($data['worker']['job_lock_timeout'], $config->getJobLockoutTime());
     $this->assertEquals($data['worker']['worker_name'], $config->getWorkerName());
 }
示例#2
0
 /**
  *  Transition to the error state
  *
  *  @access public
  *  @param DateTime $when
  *  @param string $msg
  */
 public function error(DateTime $when, $msg = '')
 {
     $this->current_state = WorkerConfig::STATE_ERROR;
     # create the transition entity
     $trans = new Transition();
     $trans->setWorker($this->getId());
     $trans->setState(WorkerConfig::STATE_ERROR);
     $trans->setOccured($when);
     $trans->setMessage($this->definition->getWorkerName() . ' Worker ERROR :: ' . $msg);
     # unlock jobs
     # raise the finish event
     $this->event->dispatch(WorkerEventsMap::WORKER_ERROR, new WorkerTransitionEvent($this, $trans));
 }