コード例 #1
0
ファイル: BufferWorker.php プロジェクト: lightster/hodor
 /**
  * @param string $queue_name
  * @param array $job
  */
 public function bufferJob($queue_name, array $job)
 {
     $job_id = $this->database->allocateId();
     $job = array_replace_recursive(['name' => "job-name-{$job_id}", 'options' => ['run_after' => date('c'), 'job_rank' => 5, 'mutex_id' => "hodor-{$job_id}"]], $job);
     $row = ['buffered_job_id' => $job_id, 'queue_name' => $queue_name, 'job_name' => $job['name'], 'job_params' => json_encode($job['params'], JSON_FORCE_OBJECT), 'buffered_at' => $job['meta']['buffered_at'], 'buffered_from' => $job['meta']['buffered_from'], 'inserted_from' => gethostname(), 'run_after' => $job['options']['run_after'], 'job_rank' => $job['options']['job_rank'], 'mutex_id' => $job['options']['mutex_id']];
     $this->database->insert('buffered_jobs', $job_id, $row);
 }
コード例 #2
0
ファイル: DatabaseTest.php プロジェクト: lightster/hodor
 /**
  * @covers ::allocateId
  */
 public function testAnIdCanBeAllocated()
 {
     $this->assertSame(1, $this->database->allocateId());
     $this->assertSame(2, $this->database->allocateId());
     $this->assertSame(3, $this->database->allocateId());
 }