コード例 #1
0
 /**
  * @covers Gloubster\Message\Presence\WorkerPresence::getArrayData
  * @covers Gloubster\Message\AbstractMessage::toJson
  * @covers Gloubster\Message\AbstractMessage::fromJson
  */
 public function testFromToJson()
 {
     $type = 'worker-type';
     $this->object->setWorkerType($type);
     $total = mt_rand();
     $this->object->setFailureJobs($total);
     $id = mt_rand();
     $this->object->setId($id);
     $memory = 123456789;
     $this->object->setMemory($memory);
     $time = 223456789.98765433;
     $this->object->setStartedTime($time);
     $time = 333456789.9876543;
     $this->object->setLastJobTime($time);
     $total = mt_rand();
     $this->object->setTotalJobs($total);
     $success = mt_rand();
     $this->object->setSuccessJobs($success);
     $time = 444456789.98765445;
     $this->object->setReportTime($time);
     $idle = true;
     $this->object->setIdle($idle);
     $this->assertEquals($this->object, WorkerPresence::fromJson($this->object->toJson()));
 }
コード例 #2
0
ファイル: AbstractWorker.php プロジェクト: gloubster/worker
 public final function sendPresence()
 {
     $presence = new WorkerPresence();
     $presence->setFailureJobs($this->jobCounter->getFailures())->setId($this->id)->setIdle(false)->setLastJobTime($this->jobCounter->getUpdateTimestamp())->setReportTime(microtime(true))->setStartedTime($this->jobCounter->getStartTimestamp())->setSuccessJobs($this->jobCounter->getSuccess())->setTotalJobs($this->jobCounter->getTotal())->setMemory(memory_get_usage())->setWorkerType($this->getType());
     $this->channel->basic_publish(new AMQPMessage($presence->toJson()), Configuration::EXCHANGE_MONITOR);
 }