summaryrefslogtreecommitdiff
path: root/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command
diff options
context:
space:
mode:
Diffstat (limited to 'intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command')
-rw-r--r--intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/AbstractCommand.php74
-rw-r--r--intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/BuryCommand.php62
-rw-r--r--intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/DeleteCommand.php53
-rw-r--r--intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/IgnoreCommand.php54
-rw-r--r--intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/KickCommand.php48
-rw-r--r--intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/KickJobCommand.php59
-rw-r--r--intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ListTubeUsedCommand.php34
-rw-r--r--intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ListTubesCommand.php35
-rw-r--r--intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ListTubesWatchedCommand.php35
-rw-r--r--intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/PauseTubeCommand.php62
-rw-r--r--intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/PeekCommand.php93
-rw-r--r--intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/PutCommand.php113
-rw-r--r--intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ReleaseCommand.php72
-rw-r--r--intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ReserveCommand.php62
-rw-r--r--intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/StatsCommand.php35
-rw-r--r--intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/StatsJobCommand.php45
-rw-r--r--intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/StatsTubeCommand.php45
-rw-r--r--intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/TouchCommand.php58
-rw-r--r--intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/UseCommand.php52
-rw-r--r--intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/WatchCommand.php44
20 files changed, 1135 insertions, 0 deletions
diff --git a/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/AbstractCommand.php b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/AbstractCommand.php
new file mode 100644
index 0000000..d966727
--- /dev/null
+++ b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/AbstractCommand.php
@@ -0,0 +1,74 @@
+<?php
+
+namespace Pheanstalk\Command;
+
+use Pheanstalk\Command;
+use Pheanstalk\Response;
+
+/**
+ * Common functionality for Command implementations.
+ *
+ * @author Paul Annesley
+ * @package Pheanstalk
+ * @license http://www.opensource.org/licenses/mit-license.php
+ */
+abstract class AbstractCommand
+ implements Command
+{
+ /* (non-phpdoc)
+ * @see Command::hasData()
+ */
+ public function hasData()
+ {
+ return false;
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getData()
+ */
+ public function getData()
+ {
+ throw new Exception\CommandException('Command has no data');
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getDataLength()
+ */
+ public function getDataLength()
+ {
+ throw new Exception\CommandException('Command has no data');
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getResponseParser()
+ */
+ public function getResponseParser()
+ {
+ // concrete implementation must either:
+ // a) implement ResponseParser
+ // b) override this getResponseParser method
+ return $this;
+ }
+
+ /**
+ * The string representation of the object.
+ * @return string
+ */
+ public function __toString()
+ {
+ return $this->getCommandLine();
+ }
+
+ // ----------------------------------------
+ // protected
+
+ /**
+ * Creates a Response for the given data
+ * @param array
+ * @return object Response
+ */
+ protected function _createResponse($name, $data = array())
+ {
+ return new Response\ArrayResponse($name, $data);
+ }
+}
diff --git a/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/BuryCommand.php b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/BuryCommand.php
new file mode 100644
index 0000000..d16a4bb
--- /dev/null
+++ b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/BuryCommand.php
@@ -0,0 +1,62 @@
+<?php
+
+namespace Pheanstalk\Command;
+
+use Pheanstalk\Exception;
+use Pheanstalk\Response;
+
+/**
+ * The 'bury' command.
+ * Puts a job into a 'buried' state, revived only by 'kick' command.
+ *
+ * @author Paul Annesley
+ * @package Pheanstalk
+ * @license http://www.opensource.org/licenses/mit-license.php
+ */
+class BuryCommand
+ extends AbstractCommand
+ implements \Pheanstalk\ResponseParser
+{
+ private $_job;
+ private $_priority;
+
+ /**
+ * @param object $job Job
+ * @param int $priority From 0 (most urgent) to 0xFFFFFFFF (least urgent)
+ */
+ public function __construct($job, $priority)
+ {
+ $this->_job = $job;
+ $this->_priority = $priority;
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getCommandLine()
+ */
+ public function getCommandLine()
+ {
+ return sprintf(
+ 'bury %u %u',
+ $this->_job->getId(),
+ $this->_priority
+ );
+ }
+
+ /* (non-phpdoc)
+ * @see ResponseParser::parseResponse()
+ */
+ public function parseResponse($responseLine, $responseData)
+ {
+ if ($responseLine == Response::RESPONSE_NOT_FOUND) {
+ throw new Exception\ServerException(sprintf(
+ '%s: Job %u is not reserved or does not exist.',
+ $responseLine,
+ $this->_job->getId()
+ ));
+ } elseif ($responseLine == Response::RESPONSE_BURIED) {
+ return $this->_createResponse(Response::RESPONSE_BURIED);
+ } else {
+ throw new Exception('Unhandled response: '.$responseLine);
+ }
+ }
+}
diff --git a/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/DeleteCommand.php b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/DeleteCommand.php
new file mode 100644
index 0000000..fd75843
--- /dev/null
+++ b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/DeleteCommand.php
@@ -0,0 +1,53 @@
+<?php
+
+namespace Pheanstalk\Command;
+
+use Pheanstalk\Exception;
+use Pheanstalk\Response;
+
+/**
+ * The 'delete' command.
+ * Permanently deletes an already-reserved job.
+ *
+ * @author Paul Annesley
+ * @package Pheanstalk
+ * @license http://www.opensource.org/licenses/mit-license.php
+ */
+class DeleteCommand
+ extends AbstractCommand
+ implements \Pheanstalk\ResponseParser
+{
+ private $_job;
+
+ /**
+ * @param object $job Job
+ */
+ public function __construct($job)
+ {
+ $this->_job = $job;
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getCommandLine()
+ */
+ public function getCommandLine()
+ {
+ return 'delete '.$this->_job->getId();
+ }
+
+ /* (non-phpdoc)
+ * @see ResponseParser::parseResponse()
+ */
+ public function parseResponse($responseLine, $responseData)
+ {
+ if ($responseLine == Response::RESPONSE_NOT_FOUND) {
+ throw new Exception\ServerException(sprintf(
+ 'Cannot delete job %u: %s',
+ $this->_job->getId(),
+ $responseLine
+ ));
+ }
+
+ return $this->_createResponse($responseLine);
+ }
+}
diff --git a/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/IgnoreCommand.php b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/IgnoreCommand.php
new file mode 100644
index 0000000..d596adb
--- /dev/null
+++ b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/IgnoreCommand.php
@@ -0,0 +1,54 @@
+<?php
+
+namespace Pheanstalk\Command;
+
+use Pheanstalk\Exception;
+use Pheanstalk\Response;
+
+/**
+ * The 'ignore' command.
+ * Removes a tube from the watch list to reserve jobs from.
+ *
+ * @author Paul Annesley
+ * @package Pheanstalk
+ * @license http://www.opensource.org/licenses/mit-license.php
+ */
+class IgnoreCommand
+ extends AbstractCommand
+ implements \Pheanstalk\ResponseParser
+{
+ private $_tube;
+
+ /**
+ * @param string $tube
+ */
+ public function __construct($tube)
+ {
+ $this->_tube = $tube;
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getCommandLine()
+ */
+ public function getCommandLine()
+ {
+ return 'ignore '.$this->_tube;
+ }
+
+ /* (non-phpdoc)
+ * @see ResponseParser::parseResponse()
+ */
+ public function parseResponse($responseLine, $responseData)
+ {
+ if (preg_match('#^WATCHING (\d+)$#', $responseLine, $matches)) {
+ return $this->_createResponse('WATCHING', array(
+ 'count' => (int) $matches[1]
+ ));
+ } elseif ($responseLine == Response::RESPONSE_NOT_IGNORED) {
+ throw new Exception\ServerException($responseLine .
+ ': cannot ignore last tube in watchlist');
+ } else {
+ throw new Exception('Unhandled response: '.$responseLine);
+ }
+ }
+}
diff --git a/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/KickCommand.php b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/KickCommand.php
new file mode 100644
index 0000000..83aba80
--- /dev/null
+++ b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/KickCommand.php
@@ -0,0 +1,48 @@
+<?php
+
+namespace Pheanstalk\Command;
+
+/**
+ * The 'kick' command.
+ * Kicks buried or delayed jobs into a 'ready' state.
+ * If there are buried jobs, it will kick up to $max of them.
+ * Otherwise, it will kick up to $max delayed jobs.
+ *
+ * @author Paul Annesley
+ * @package Pheanstalk
+ * @license http://www.opensource.org/licenses/mit-license.php
+ */
+class KickCommand
+ extends AbstractCommand
+ implements \Pheanstalk\ResponseParser
+{
+ private $_max;
+
+ /**
+ * @param int $max The maximum number of jobs to kick
+ */
+ public function __construct($max)
+ {
+ $this->_max = (int) $max;
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getCommandLine()
+ */
+ public function getCommandLine()
+ {
+ return 'kick '.$this->_max;
+ }
+
+ /* (non-phpdoc)
+ * @see ResponseParser::parseResponse()
+ */
+ public function parseResponse($responseLine, $responseData)
+ {
+ list($code, $count) = explode(' ', $responseLine);
+
+ return $this->_createResponse($code, array(
+ 'kicked' => (int) $count,
+ ));
+ }
+}
diff --git a/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/KickJobCommand.php b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/KickJobCommand.php
new file mode 100644
index 0000000..e376754
--- /dev/null
+++ b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/KickJobCommand.php
@@ -0,0 +1,59 @@
+<?php
+
+namespace Pheanstalk\Command;
+
+use Pheanstalk\Exception;
+use Pheanstalk\Response;
+
+/**
+ * The 'kick-job' command.
+ * Kicks a specific buried or delayed job into a 'ready' state.
+ *
+ * A variant of kick that operates with a single job. If the given job
+ * 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.
+ *
+ * @author Matthieu Napoli
+ * @package Pheanstalk
+ * @license http://www.opensource.org/licenses/mit-license.php
+ */
+class KickJobCommand
+ extends AbstractCommand
+ implements \Pheanstalk\ResponseParser
+{
+ private $_job;
+
+ /**
+ * @param Job $job Pheanstalk job
+ */
+ public function __construct($job)
+ {
+ $this->_job = $job;
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getCommandLine()
+ */
+ public function getCommandLine()
+ {
+ return 'kick-job '.$this->_job->getId();
+ }
+
+ /* (non-phpdoc)
+ * @see ResponseParser::parseResponse()
+ */
+ public function parseResponse($responseLine, $responseData)
+ {
+ if ($responseLine == Response::RESPONSE_NOT_FOUND) {
+ throw new Exception\ServerException(sprintf(
+ '%s: Job %d does not exist or is not in a kickable state.',
+ $responseLine,
+ $this->_job->getId()
+ ));
+ } elseif ($responseLine == Response::RESPONSE_KICKED) {
+ return $this->_createResponse(Response::RESPONSE_KICKED);
+ } else {
+ throw new Exception('Unhandled response: '.$responseLine);
+ }
+ }
+}
diff --git a/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ListTubeUsedCommand.php b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ListTubeUsedCommand.php
new file mode 100644
index 0000000..55b100f
--- /dev/null
+++ b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ListTubeUsedCommand.php
@@ -0,0 +1,34 @@
+<?php
+
+namespace Pheanstalk\Command;
+
+/**
+ * The 'list-tube-used' command.
+ * Returns the tube currently being used by the client.
+ *
+ * @author Paul Annesley
+ * @package Pheanstalk
+ * @license http://www.opensource.org/licenses/mit-license.php
+ */
+class ListTubeUsedCommand
+ extends AbstractCommand
+ implements \Pheanstalk\ResponseParser
+{
+ /* (non-phpdoc)
+ * @see Command::getCommandLine()
+ */
+ public function getCommandLine()
+ {
+ return 'list-tube-used';
+ }
+
+ /* (non-phpdoc)
+ * @see ResponseParser::parseResponse()
+ */
+ public function parseResponse($responseLine, $responseData)
+ {
+ return $this->_createResponse('USING', array(
+ 'tube' => preg_replace('#^USING (.+)$#', '$1', $responseLine)
+ ));
+ }
+}
diff --git a/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ListTubesCommand.php b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ListTubesCommand.php
new file mode 100644
index 0000000..f0ea5a1
--- /dev/null
+++ b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ListTubesCommand.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace Pheanstalk\Command;
+
+use Pheanstalk\YamlResponseParser;
+
+/**
+ * The 'list-tubes' command.
+ * List all existing tubes.
+ *
+ * @author Paul Annesley
+ * @package Pheanstalk
+ * @license http://www.opensource.org/licenses/mit-license.php
+ */
+class ListTubesCommand
+ extends AbstractCommand
+{
+ /* (non-phpdoc)
+ * @see Command::getCommandLine()
+ */
+ public function getCommandLine()
+ {
+ return 'list-tubes';
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getResponseParser()
+ */
+ public function getResponseParser()
+ {
+ return new YamlResponseParser(
+ YamlResponseParser::MODE_LIST
+ );
+ }
+}
diff --git a/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ListTubesWatchedCommand.php b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ListTubesWatchedCommand.php
new file mode 100644
index 0000000..d66158f
--- /dev/null
+++ b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ListTubesWatchedCommand.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace Pheanstalk\Command;
+
+use Pheanstalk\YamlResponseParser;
+
+/**
+ * The 'list-tubes-watched' command.
+ * Lists the tubes on the watchlist.
+ *
+ * @author Paul Annesley
+ * @package Pheanstalk
+ * @license http://www.opensource.org/licenses/mit-license.php
+ */
+class ListTubesWatchedCommand
+ extends AbstractCommand
+{
+ /* (non-phpdoc)
+ * @see Command::getCommandLine()
+ */
+ public function getCommandLine()
+ {
+ return 'list-tubes-watched';
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getResponseParser()
+ */
+ public function getResponseParser()
+ {
+ return new YamlResponseParser(
+ YamlResponseParser::MODE_LIST
+ );
+ }
+}
diff --git a/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/PauseTubeCommand.php b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/PauseTubeCommand.php
new file mode 100644
index 0000000..5483a1a
--- /dev/null
+++ b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/PauseTubeCommand.php
@@ -0,0 +1,62 @@
+<?php
+
+namespace Pheanstalk\Command;
+
+use Pheanstalk\Exception;
+use Pheanstalk\Response;
+
+/**
+ * The 'pause-tube' command.
+ * Temporarily prevent jobs being reserved from the given tube.
+ *
+ * @author Paul Annesley
+ * @package Pheanstalk
+ * @license http://www.opensource.org/licenses/mit-license.php
+ */
+class PauseTubeCommand
+ extends AbstractCommand
+ implements \Pheanstalk\ResponseParser
+{
+ private $_tube;
+ private $_delay;
+
+ /**
+ * @param string $tube The tube to pause
+ * @param int $delay Seconds before jobs may be reserved from this queue.
+ */
+ public function __construct($tube, $delay)
+ {
+ $this->_tube = $tube;
+ $this->_delay = $delay;
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getCommandLine()
+ */
+ public function getCommandLine()
+ {
+ return sprintf(
+ 'pause-tube %s %u',
+ $this->_tube,
+ $this->_delay
+ );
+ }
+
+ /* (non-phpdoc)
+ * @see ResponseParser::parseResponse()
+ */
+ public function parseResponse($responseLine, $responseData)
+ {
+ if ($responseLine == Response::RESPONSE_NOT_FOUND) {
+ throw new Exception\ServerException(sprintf(
+ '%s: tube %s does not exist.',
+ $responseLine,
+ $this->_tube
+ ));
+ } elseif ($responseLine == Response::RESPONSE_PAUSED) {
+ return $this->_createResponse(Response::RESPONSE_PAUSED);
+ } else {
+ throw new Exception('Unhandled response: '.$responseLine);
+ }
+ }
+}
diff --git a/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/PeekCommand.php b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/PeekCommand.php
new file mode 100644
index 0000000..b76c7ec
--- /dev/null
+++ b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/PeekCommand.php
@@ -0,0 +1,93 @@
+<?php
+
+namespace Pheanstalk\Command;
+
+use Pheanstalk\Exception;
+use Pheanstalk\Response;
+
+/**
+ * The 'peek', 'peek-ready', 'peek-delayed' and 'peek-buried' commands.
+ *
+ * The peek commands let the client inspect a job in the system. There are four
+ * variations. All but the first (peek) operate only on the currently used tube.
+ *
+ * @author Paul Annesley
+ * @package Pheanstalk
+ * @license http://www.opensource.org/licenses/mit-license.php
+ */
+class PeekCommand
+ extends AbstractCommand
+ implements \Pheanstalk\ResponseParser
+{
+ const TYPE_ID = 'id';
+ const TYPE_READY = 'ready';
+ const TYPE_DELAYED = 'delayed';
+ const TYPE_BURIED = 'buried';
+
+ private $_subcommands = array(
+ self::TYPE_READY,
+ self::TYPE_DELAYED,
+ self::TYPE_BURIED,
+ );
+
+ private $_subcommand;
+ private $_jobId;
+
+ /**
+ * @param mixed $peekSubject Job ID or self::TYPE_*
+ */
+ public function __construct($peekSubject)
+ {
+ if (is_int($peekSubject) || ctype_digit($peekSubject)) {
+ $this->_jobId = $peekSubject;
+ } elseif (in_array($peekSubject, $this->_subcommands)) {
+ $this->_subcommand = $peekSubject;
+ } else {
+ throw new Exception\CommandException(sprintf(
+ 'Invalid peek subject: %s', $peekSubject
+ ));
+ }
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getCommandLine()
+ */
+ public function getCommandLine()
+ {
+ return isset($this->_jobId) ?
+ sprintf('peek %u', $this->_jobId) :
+ sprintf('peek-%s', $this->_subcommand);
+ }
+
+ /* (non-phpdoc)
+ * @see ResponseParser::parseResponse()
+ */
+ public function parseResponse($responseLine, $responseData)
+ {
+ if ($responseLine == Response::RESPONSE_NOT_FOUND) {
+ if (isset($this->_jobId)) {
+ $message = sprintf(
+ '%s: Job %u does not exist.',
+ $responseLine,
+ $this->_jobId
+ );
+ } else {
+ $message = sprintf(
+ "%s: There are no jobs in the '%s' status",
+ $responseLine,
+ $this->_subcommand
+ );
+ }
+
+ throw new Exception\ServerException($message);
+ } elseif (preg_match('#^FOUND (\d+) \d+$#', $responseLine, $matches)) {
+ return $this->_createResponse(
+ Response::RESPONSE_FOUND,
+ array(
+ 'id' => (int) $matches[1],
+ 'jobdata' => $responseData,
+ )
+ );
+ }
+ }
+}
diff --git a/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/PutCommand.php b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/PutCommand.php
new file mode 100644
index 0000000..1e61c2c
--- /dev/null
+++ b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/PutCommand.php
@@ -0,0 +1,113 @@
+<?php
+
+namespace Pheanstalk\Command;
+
+use Pheanstalk\Exception;
+
+/**
+ * The 'put' command.
+ * Inserts a job into the client's currently used tube.
+ * @see UseCommand
+ *
+ * @author Paul Annesley
+ * @package Pheanstalk
+ * @license http://www.opensource.org/licenses/mit-license.php
+ */
+class PutCommand
+ extends AbstractCommand
+ implements \Pheanstalk\ResponseParser
+{
+ private $_data;
+ private $_priority;
+ private $_delay;
+ private $_ttr;
+
+ /**
+ * Puts a job on the queue
+ * @param string $data The job data
+ * @param int $priority From 0 (most urgent) to 0xFFFFFFFF (least urgent)
+ * @param int $delay Seconds to wait before job becomes ready
+ * @param int $ttr Time To Run: seconds a job can be reserved for
+ */
+ public function __construct($data, $priority, $delay, $ttr)
+ {
+ $this->_data = $data;
+ $this->_priority = $priority;
+ $this->_delay = $delay;
+ $this->_ttr = $ttr;
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getCommandLine()
+ */
+ public function getCommandLine()
+ {
+ return sprintf(
+ 'put %u %u %u %u',
+ $this->_priority,
+ $this->_delay,
+ $this->_ttr,
+ $this->getDataLength()
+ );
+ }
+
+ /* (non-phpdoc)
+ * @see Command::hasData()
+ */
+ public function hasData()
+ {
+ return true;
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getData()
+ */
+ public function getData()
+ {
+ return $this->_data;
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getDataLength()
+ */
+ public function getDataLength()
+ {
+ if (function_exists('mb_strlen')) {
+ return mb_strlen($this->_data, "latin1");
+ } else {
+ return strlen($this->_data);
+ }
+ }
+
+ /* (non-phpdoc)
+ * @see ResponseParser::parseResponse()
+ */
+ public function parseResponse($responseLine, $responseData)
+ {
+ if (preg_match('#^INSERTED (\d+)$#', $responseLine, $matches)) {
+ return $this->_createResponse('INSERTED', array(
+ 'id' => (int) $matches[1]
+ ));
+ } elseif (preg_match('#^BURIED (\d)+$#', $responseLine, $matches)) {
+ throw new Exception(sprintf(
+ '%s: server ran out of memory trying to grow the priority queue data structure.',
+ $responseLine
+ ));
+ } elseif (preg_match('#^JOB_TOO_BIG$#', $responseLine)) {
+ throw new Exception(sprintf(
+ '%s: job data exceeds server-enforced limit',
+ $responseLine
+ ));
+ } elseif (preg_match('#^EXPECTED_CRLF#', $responseLine)) {
+ throw new Exception(sprintf(
+ '%s: CRLF expected',
+ $responseLine
+ ));
+ } else {
+ throw new Exception(sprintf(
+ 'Unhandled response: %s',
+ $responseLine
+ ));
+ }
+ }
+}
diff --git a/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ReleaseCommand.php b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ReleaseCommand.php
new file mode 100644
index 0000000..33161a0
--- /dev/null
+++ b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ReleaseCommand.php
@@ -0,0 +1,72 @@
+<?php
+
+namespace Pheanstalk\Command;
+
+use Pheanstalk\Exception;
+use Pheanstalk\Response;
+
+/**
+ * The 'release' command.
+ * Releases a reserved job back onto the ready queue.
+ *
+ * @author Paul Annesley
+ * @package Pheanstalk
+ * @license http://www.opensource.org/licenses/mit-license.php
+ */
+class ReleaseCommand
+ extends AbstractCommand
+ implements \Pheanstalk\ResponseParser
+{
+ private $_job;
+ private $_priority;
+ private $_delay;
+
+ /**
+ * @param object $job Job
+ * @param int $priority From 0 (most urgent) to 0xFFFFFFFF (least urgent)
+ * @param int $delay Seconds to wait before job becomes ready
+ */
+ public function __construct($job, $priority, $delay)
+ {
+ $this->_job = $job;
+ $this->_priority = $priority;
+ $this->_delay = $delay;
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getCommandLine()
+ */
+ public function getCommandLine()
+ {
+ return sprintf(
+ 'release %u %u %u',
+ $this->_job->getId(),
+ $this->_priority,
+ $this->_delay
+ );
+ }
+
+ /* (non-phpdoc)
+ * @see ResponseParser::parseResponse()
+ */
+ public function parseResponse($responseLine, $responseData)
+ {
+ if ($responseLine == Response::RESPONSE_BURIED) {
+ throw new Exception\ServerException(sprintf(
+ 'Job %u %s: out of memory trying to grow data structure',
+ $this->_job->getId(),
+ $responseLine
+ ));
+ }
+
+ if ($responseLine == Response::RESPONSE_NOT_FOUND) {
+ throw new Exception\ServerException(sprintf(
+ 'Job %u %s: does not exist or is not reserved by client',
+ $this->_job->getId(),
+ $responseLine
+ ));
+ }
+
+ return $this->_createResponse($responseLine);
+ }
+}
diff --git a/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ReserveCommand.php b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ReserveCommand.php
new file mode 100644
index 0000000..9d4ccc8
--- /dev/null
+++ b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ReserveCommand.php
@@ -0,0 +1,62 @@
+<?php
+
+namespace Pheanstalk\Command;
+
+use Pheanstalk\Response;
+
+/**
+ * The 'reserve' command.
+ * Reserves/locks a ready job in a watched tube.
+ *
+ * @author Paul Annesley
+ * @package Pheanstalk
+ * @license http://www.opensource.org/licenses/mit-license.php
+ */
+class ReserveCommand
+ extends AbstractCommand
+ implements \Pheanstalk\ResponseParser
+{
+ private $_timeout;
+
+ /**
+ * A timeout value of 0 will cause the server to immediately return either a
+ * response or TIMED_OUT. A positive value of timeout will limit the amount of
+ * time the client will block on the reserve request until a job becomes
+ * available.
+ *
+ * @param int $timeout
+ */
+ public function __construct($timeout = null)
+ {
+ $this->_timeout = $timeout;
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getCommandLine()
+ */
+ public function getCommandLine()
+ {
+ return isset($this->_timeout) ?
+ sprintf('reserve-with-timeout %s', $this->_timeout) :
+ 'reserve';
+ }
+
+ /* (non-phpdoc)
+ * @see ResponseParser::parseResponse()
+ */
+ public function parseResponse($responseLine, $responseData)
+ {
+ if ($responseLine === Response::RESPONSE_DEADLINE_SOON ||
+ $responseLine === Response::RESPONSE_TIMED_OUT)
+ {
+ return $this->_createResponse($responseLine);
+ }
+
+ list($code, $id) = explode(' ', $responseLine);
+
+ return $this->_createResponse($code, array(
+ 'id' => (int) $id,
+ 'jobdata' => $responseData,
+ ));
+ }
+}
diff --git a/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/StatsCommand.php b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/StatsCommand.php
new file mode 100644
index 0000000..907613a
--- /dev/null
+++ b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/StatsCommand.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace Pheanstalk\Command;
+
+use Pheanstalk\YamlResponseParser;
+
+/**
+ * The 'stats' command.
+ * Statistical information about the system as a whole.
+ *
+ * @author Paul Annesley
+ * @package Pheanstalk
+ * @license http://www.opensource.org/licenses/mit-license.php
+ */
+class StatsCommand
+ extends AbstractCommand
+{
+ /* (non-phpdoc)
+ * @see Command::getCommandLine()
+ */
+ public function getCommandLine()
+ {
+ return 'stats';
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getResponseParser()
+ */
+ public function getResponseParser()
+ {
+ return new YamlResponseParser(
+ YamlResponseParser::MODE_DICT
+ );
+ }
+}
diff --git a/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/StatsJobCommand.php b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/StatsJobCommand.php
new file mode 100644
index 0000000..ad8c235
--- /dev/null
+++ b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/StatsJobCommand.php
@@ -0,0 +1,45 @@
+<?php
+
+namespace Pheanstalk\Command;
+
+use Pheanstalk\YamlResponseParser;
+
+/**
+ * The 'stats-job' command.
+ * Gives statistical information about the specified job if it exists.
+ *
+ * @author Paul Annesley
+ * @package Pheanstalk
+ * @license http://www.opensource.org/licenses/mit-license.php
+ */
+class StatsJobCommand
+ extends AbstractCommand
+{
+ private $_jobId;
+
+ /**
+ * @param Job|int $job
+ */
+ public function __construct($job)
+ {
+ $this->_jobId = is_object($job) ? $job->getId() : $job;
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getCommandLine()
+ */
+ public function getCommandLine()
+ {
+ return sprintf('stats-job %u', $this->_jobId);
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getResponseParser()
+ */
+ public function getResponseParser()
+ {
+ return new YamlResponseParser(
+ YamlResponseParser::MODE_DICT
+ );
+ }
+}
diff --git a/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/StatsTubeCommand.php b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/StatsTubeCommand.php
new file mode 100644
index 0000000..d0711fa
--- /dev/null
+++ b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/StatsTubeCommand.php
@@ -0,0 +1,45 @@
+<?php
+
+namespace Pheanstalk\Command;
+
+use Pheanstalk\YamlResponseParser;
+
+/**
+ * The 'stats-tube' command.
+ * Gives statistical information about the specified tube if it exists.
+ *
+ * @author Paul Annesley
+ * @package Pheanstalk
+ * @license http://www.opensource.org/licenses/mit-license.php
+ */
+class StatsTubeCommand
+ extends AbstractCommand
+{
+ private $_tube;
+
+ /**
+ * @param string $tube
+ */
+ public function __construct($tube)
+ {
+ $this->_tube = $tube;
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getCommandLine()
+ */
+ public function getCommandLine()
+ {
+ return sprintf('stats-tube %s', $this->_tube);
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getResponseParser()
+ */
+ public function getResponseParser()
+ {
+ return new YamlResponseParser(
+ YamlResponseParser::MODE_DICT
+ );
+ }
+}
diff --git a/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/TouchCommand.php b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/TouchCommand.php
new file mode 100644
index 0000000..89b9eb5
--- /dev/null
+++ b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/TouchCommand.php
@@ -0,0 +1,58 @@
+<?php
+
+namespace Pheanstalk\Command;
+
+use Pheanstalk\Exception;
+use Pheanstalk\Response;
+
+/**
+ * The 'touch' command.
+ *
+ * The "touch" command allows a worker to request more time to work on a job.
+ * This is useful for jobs that potentially take a long time, but you still want
+ * the benefits of a TTR pulling a job away from an unresponsive worker. A worker
+ * may periodically tell the server that it's still alive and processing a job
+ * (e.g. it may do this on DEADLINE_SOON).
+ *
+ * @author Paul Annesley
+ * @package Pheanstalk
+ * @license http://www.opensource.org/licenses/mit-license.php
+ */
+class TouchCommand
+ extends AbstractCommand
+ implements \Pheanstalk\ResponseParser
+{
+ private $_job;
+
+ /**
+ * @param Job $job
+ */
+ public function __construct($job)
+ {
+ $this->_job = $job;
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getCommandLine()
+ */
+ public function getCommandLine()
+ {
+ return sprintf('touch %u', $this->_job->getId());
+ }
+
+ /* (non-phpdoc)
+ * @see ResponseParser::parseResponse()
+ */
+ public function parseResponse($responseLine, $responseData)
+ {
+ if ($responseLine == Response::RESPONSE_NOT_FOUND) {
+ throw new Exception\ServerException(sprintf(
+ 'Job %u %s: does not exist or is not reserved by client',
+ $this->_job->getId(),
+ $responseLine
+ ));
+ }
+
+ return $this->_createResponse($responseLine);
+ }
+}
diff --git a/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/UseCommand.php b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/UseCommand.php
new file mode 100644
index 0000000..5e5ba70
--- /dev/null
+++ b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/UseCommand.php
@@ -0,0 +1,52 @@
+<?php
+
+namespace Pheanstalk\Command;
+
+use Pheanstalk\ResponseParser;
+
+/**
+ * The 'use' command.
+ *
+ * The "use" command is for producers. Subsequent put commands will put jobs into
+ * the tube specified by this command. If no use command has been issued, jobs
+ * will be put into the tube named "default".
+ *
+ * @author Paul Annesley
+ * @package Pheanstalk
+ * @license http://www.opensource.org/licenses/mit-license.php
+ */
+class UseCommand
+ extends AbstractCommand
+ implements \Pheanstalk\ResponseParser
+{
+ /**
+ * @var string
+ */
+ private $_tube;
+
+ /**
+ * @param string $tube The name of the tube to use
+ */
+ public function __construct($tube)
+ {
+ $this->_tube = $tube;
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getCommandLine()
+ */
+ public function getCommandLine()
+ {
+ return 'use '.$this->_tube;
+ }
+
+ /* (non-phpdoc)
+ * @see ResponseParser::parseResponse()
+ */
+ public function parseResponse($responseLine, $responseData)
+ {
+ return $this->_createResponse('USING', array(
+ 'tube' => preg_replace('#^USING (.+)$#', '$1', $responseLine)
+ ));
+ }
+}
diff --git a/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/WatchCommand.php b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/WatchCommand.php
new file mode 100644
index 0000000..07dca67
--- /dev/null
+++ b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/WatchCommand.php
@@ -0,0 +1,44 @@
+<?php
+
+namespace Pheanstalk\Command;
+
+/**
+ * The 'watch' command.
+ * Adds a tube to the watchlist to reserve jobs from.
+ *
+ * @author Paul Annesley
+ * @package Pheanstalk
+ * @license http://www.opensource.org/licenses/mit-license.php
+ */
+class WatchCommand
+ extends AbstractCommand
+ implements \Pheanstalk\ResponseParser
+{
+ private $_tube;
+
+ /**
+ * @param string $tube
+ */
+ public function __construct($tube)
+ {
+ $this->_tube = $tube;
+ }
+
+ /* (non-phpdoc)
+ * @see Command::getCommandLine()
+ */
+ public function getCommandLine()
+ {
+ return 'watch '.$this->_tube;
+ }
+
+ /* (non-phpdoc)
+ * @see ResponseParser::parseResponse()
+ */
+ public function parseResponse($responseLine, $responseData)
+ {
+ return $this->_createResponse('WATCHING', array(
+ 'count' => preg_replace('#^WATCHING (.+)$#', '$1', $responseLine)
+ ));
+ }
+}