From 95c15758b50144105064d2613d1e9a9da23d4e7c Mon Sep 17 00:00:00 2001 From: horus_arch Date: Mon, 20 Feb 2017 12:42:43 +0100 Subject: Committed vendor/ for lazyness. --- .../pda/pheanstalk/src/Command/AbstractCommand.php | 74 ++++++++++++++ .../pda/pheanstalk/src/Command/BuryCommand.php | 62 +++++++++++ .../pda/pheanstalk/src/Command/DeleteCommand.php | 53 ++++++++++ .../pda/pheanstalk/src/Command/IgnoreCommand.php | 54 ++++++++++ .../pda/pheanstalk/src/Command/KickCommand.php | 48 +++++++++ .../pda/pheanstalk/src/Command/KickJobCommand.php | 59 +++++++++++ .../pheanstalk/src/Command/ListTubeUsedCommand.php | 34 +++++++ .../pheanstalk/src/Command/ListTubesCommand.php | 35 +++++++ .../src/Command/ListTubesWatchedCommand.php | 35 +++++++ .../pheanstalk/src/Command/PauseTubeCommand.php | 62 +++++++++++ .../pda/pheanstalk/src/Command/PeekCommand.php | 93 +++++++++++++++++ .../pda/pheanstalk/src/Command/PutCommand.php | 113 +++++++++++++++++++++ .../pda/pheanstalk/src/Command/ReleaseCommand.php | 72 +++++++++++++ .../pda/pheanstalk/src/Command/ReserveCommand.php | 62 +++++++++++ .../pda/pheanstalk/src/Command/StatsCommand.php | 35 +++++++ .../pda/pheanstalk/src/Command/StatsJobCommand.php | 45 ++++++++ .../pheanstalk/src/Command/StatsTubeCommand.php | 45 ++++++++ .../pda/pheanstalk/src/Command/TouchCommand.php | 58 +++++++++++ .../pda/pheanstalk/src/Command/UseCommand.php | 52 ++++++++++ .../pda/pheanstalk/src/Command/WatchCommand.php | 44 ++++++++ 20 files changed, 1135 insertions(+) create mode 100644 intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/AbstractCommand.php create mode 100644 intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/BuryCommand.php create mode 100644 intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/DeleteCommand.php create mode 100644 intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/IgnoreCommand.php create mode 100644 intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/KickCommand.php create mode 100644 intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/KickJobCommand.php create mode 100644 intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ListTubeUsedCommand.php create mode 100644 intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ListTubesCommand.php create mode 100644 intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ListTubesWatchedCommand.php create mode 100644 intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/PauseTubeCommand.php create mode 100644 intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/PeekCommand.php create mode 100644 intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/PutCommand.php create mode 100644 intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ReleaseCommand.php create mode 100644 intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/ReserveCommand.php create mode 100644 intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/StatsCommand.php create mode 100644 intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/StatsJobCommand.php create mode 100644 intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/StatsTubeCommand.php create mode 100644 intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/TouchCommand.php create mode 100644 intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/UseCommand.php create mode 100644 intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/WatchCommand.php (limited to 'intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command') 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 @@ +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 @@ +_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 @@ +_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 @@ +_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 @@ +_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 @@ +_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 @@ +_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 @@ +_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 @@ +_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 @@ +_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 @@ +_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 @@ +_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 @@ +_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 @@ +_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 @@ +_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 @@ +_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 @@ +_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) + )); + } +} -- cgit v1.2.3