/**
- Inspect the job with the shortest delay left.
-
- @return string|boolean
false on error otherwise the body of the job.
*/
public function peekDelayed() {
$this->_write('peek-delayed');
return $this->_peekRead();
}
/**
- Inspect the next job in the list of buried jobs.
-
- @return string|boolean
false on error otherwise the body of the job.
*/
public function peekBuried() {
$this->_write('peek-buried');
return $this->_peekRead();
}
/**
- Handles response for all peek methods.
-
- @return string|boolean
false on error otherwise the body of the job.
*/
protected function _peekRead() {
$status = strtok($this->_read(),' ');
switch ($status) {
case 'FOUND':
return [
'id' => (integer) strtok(' '),'body' => $this->_read((integer) strtok(' '))
];
case 'NOT_FOUND':
default:
$this->_error($status);
return false;
}
}
/**
- Moves jobs into the ready queue (applies to the current tube).
-
- If there are buried jobs those get kicked only otherwise delayed
- jobs get kicked.
-
- @param integer $bound Upper bound on the number of jobs to kick.
- @return integer|boolean False on error otherwise number of jobs kicked.
*/
public function kick($bound) {
$this->_write(sprintf('kick %d',$bound));
$status = strtok($this->_read(),' ');
switch ($status) {
case 'KICKED':
return (integer) strtok(' ');
default:
$this->_error($status);
return false;
}
}
/**
- This is a variant of the kick command that operates with a single
- job identified by its job id. If the given job id exists and is in a
- buried or delayed state,it will be moved to the ready queue of the
- the same tube where it currently belongs.
-
- @param integer $id The job id.
- @return boolean
false on error true otherwise.
*/
public function kickJob($id) {
$this->_write(sprintf('kick-job %d',$id));
$status = strtok($this->_read(),' ');
switch ($status) {
case 'KICKED':
return true;
case 'NOT_FOUND':
default:
$this->_error($status);
return false;
}
}
/ Stats Commands /
/**
- Gives statistical information about the specified job if it exists.
-
- @param integer $id The job id.
- @return string|boolean
false on error otherwise a string with a yaml formatted dictionary.
*/
public function statsJob($id) {
$this->_write(sprintf('stats-job %d',$id));
return $this->_statsRead();
}
/**
- Gives statistical information about the specified tube if it exists.
-
- @param string $tube Name of the tube.
- @return string|boolean
false on error otherwise a string with a yaml formatted dictionary.
*/
public function statsTube($tube) {
$this->_write(sprintf('stats-tube %s',$tube));
return $this->_statsRead();
}
/**
- Gives statistical information about the system as a whole.
-
- @return string|boolean
false on error otherwise a string with a yaml formatted dictionary.
*/
public function stats() {
$this->_write('stats');
return $this->_statsRead();
}
/**
- Returns a list of all existing tubes.
-
- @return string|boolean
false on error otherwise a string with a yaml formatted list.
*/
public function listTubes() {
$this->_write('list-tubes');
return $this->_statsRead();
}
/**
- Returns the tube currently being used by the producer.
-
- @return string|boolean
false on error otherwise a string with the name of the tube.
*/
public function listTubeUsed() {
$this->_write('list-tube-used');
$status = strtok($this->_read(),' ');
switch ($status) {
case 'USING':
return strtok(' ');
default:
$this->_error($status);
return false;
}
}
/**
- Returns a list of tubes currently being watched by the worker.
-
- @return string|boolean
false on error otherwise a string with a yaml formatted list.
*/
public function listTubesWatched() {
$this->_write('list-tubes-watched');
return $this->_statsRead();
}
(编辑:晋中站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|