/** * 设置错误 * * @param \Exception|null $error * @return mixed */ public function error($error = null) { if ($error === null) { return $this->injectors['error']; } if ($error instanceof \Exception) { $str = get_class($error) . ' Error on: ' . $error->getFile() . ' ' . $error->getLine() . ' '; $str .= 'Error Msg: ' . $error->getMessage() . ' '; $str .= 'Error Code: ' . $error->getCode() . ' '; $str .= 'Trace: ' . $error->getTraceAsString(); } else { $str = $error; } $this->set('error', $str); $this->set('failed_at', Util::now()); if ($this->queue->distributed) { $this->client->del($this->queue->name . ':' . self::JOB_TAB . ':' . $this->injectors['id'] . ':lock'); } }
/** * 改变状态 * * @param $state * @return $this */ protected function state($state) { $setKey = $this->queue->name . ':' . self::JOBS_TAB; $this->client->zRem($setKey . ':' . $this->injectors['state'], $this->injectors['id']); $this->client->zRem($setKey . ':' . $this->injectors['tube'] . ':' . $this->injectors['state'], $this->injectors['id']); $this->set('state', $state); $score = $this->injectors['timing']; $this->client->zAdd($setKey . ':' . $state, $score, $this->injectors['id']); $this->client->zAdd($setKey . ':' . $this->injectors['tube'] . ':' . $state, $score, $this->injectors['id']); $this->set('updated_at', Util::now()); return $this; }