저자: Vasily Zorin (maintainer@daemon.io)
상속: extends MongoId
예제 #1
0
 /**
  * @param $cb
  * @param $type
  * @param $args
  */
 public function enqueue($cb, $type, $args, $add = [], $pushcb = null)
 {
     $ts = microtime(true);
     return $this->appInstance->jobqueue->push($type, $args, $ts, $add, function ($job) use($cb, $pushcb) {
         if ($cb !== NULL) {
             $this->callbacks[(string) MongoId::import($job->getId())] = CallbackWrapper::wrap($cb);
         }
         if ($pushcb !== null) {
             call_user_func($pushcb);
         }
     });
 }
예제 #2
0
 public static function resultMap(&$m)
 {
     if (is_array($m)) {
         foreach ($m as &$v) {
             static::resultMap($v);
         }
     } else {
         if ($m instanceof \WakePHP\Objects\Generic) {
             $m = $m->toArray();
             static::resultMap($m);
         } elseif ($m instanceof \MongoBinData) {
             $m = base64_encode($m->bin);
         } elseif ($m instanceof \MongoId) {
             $m = (string) MongoId::import($m, true);
         } elseif ($m instanceof MongoId) {
             $m = (string) $m;
         }
     }
 }
예제 #3
0
 /**
  * getPlainObject
  * @return \MongoId
  */
 public function getPlainObject()
 {
     return new \MongoId(parent::__toString());
 }
예제 #4
0
 public function getJobInfo($id, $accesskey, $cb)
 {
     $id = MongoId::import($id);
     $this->getJob($accesskey !== null ? ['_id' => $id, 'accesskey' => (string) $accesskey] : ['_id' => $id], $cb);
 }
예제 #5
0
파일: Job.php 프로젝트: kakserpom/WakePHP
 public function sendResult($result)
 {
     $this['status'] = $result !== false ? 's' : 'f';
     if ($this['status'] === 's') {
         $this->progress = 1;
     }
     $this['result'] = $result;
     $this->cond = ['_id' => $this->getId(), 'worker' => $this->orm->appInstance->ipcId];
     $this->save(function () {
         $id = (string) MongoId::import($this->getId());
         foreach ($this['instance'] as $i) {
             $this->orm->appInstance->redis->publish($this->orm->appInstance->config->redisprefix->value . 'jobFinished:' . MongoId::import($i), $id);
         }
     });
     $this->orm->appInstance->unlinkJob($this);
 }
예제 #6
0
 public function condSetId($id)
 {
     if (func_num_args() === 2) {
         $k = func_get_arg(0);
         $id = func_get_arg(1);
     } else {
         $k = '_id';
     }
     $id = MongoId::import($s = $id);
     if (!$id) {
         throw new WrongCondition('condSetId: wrong value: ' . $s);
     }
     $this->cond[$k] = $id;
     return $this;
 }