예제 #1
0
 /**
  * @param array $job
  */
 private function batchJob(array $job)
 {
     $db = $this->database;
     if (0 === $this->jobs_queued) {
         $this->worker_queue_factory->beginBatch();
         $db->beginBatch();
     }
     $meta = $db->markJobAsQueued($job);
     $queue = $this->worker_queue_factory->getQueue($job['queue_name']);
     $queue->push($job['job_name'], $job['job_params'], $meta);
     ++$this->jobs_queued;
     $this->publishBatchIfNecessary();
 }
예제 #2
0
 /**
  * @covers ::__construct
  * @covers ::push
  * @covers ::<private>
  * @covers \Hodor\JobQueue\AbstractQueueFactory
  * @covers \Hodor\JobQueue\WorkerQueueFactory
  * @expectedException Exception
  */
 public function testBatchedJobIsDiscardedIfBatchIsDiscarded()
 {
     $uniqid = uniqid();
     $expected_job = ['name' => "some-job-{$uniqid}", 'params' => ['value' => $uniqid], 'meta' => ['buffered_job_id' => rand(1, 10)]];
     $this->worker_queue_factory->beginBatch();
     $this->worker_queue->push($expected_job['name'], $expected_job['params'], $expected_job['meta']);
     $this->worker_queue_factory->discardBatch();
     $this->consumer->consume(function () {
     });
 }