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()); }
/** * Have the worker receive jobs. * * @return LaterJob\Allocator * @access public */ public function receive(DateTime $now) { $jobs_to_process = $this->definition->getJobsToProcess(); $lockout_time = $this->definition->getJobLockoutTime(); $worker_id = $this->getId(); # add the lockout to the date argument $lockout = clone $now; $lockout->modify('+' . $lockout_time . ' seconds'); # call the receive on the allocator to lock a list of jobs $this->allocator->receive($jobs_to_process, $worker_id, $lockout, $now); # return the allocator so processing script can iterate over # the job list return $this->allocator; }