From 0e722df94324d9173f368364402837b301d20048 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Fri, 9 Oct 2020 19:21:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Kafka/Consumer.php | 109 +++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 54 deletions(-) diff --git a/Kafka/Consumer.php b/Kafka/Consumer.php index 108058eb..d22d11b5 100644 --- a/Kafka/Consumer.php +++ b/Kafka/Consumer.php @@ -18,66 +18,67 @@ use function Amp\run; /** * +------------------------------------------------------------------------------ -* Kafka protocol since Kafka v0.8 -* +------------------------------------------------------------------------------ -* -* @package -* @version $_SWANBR_VERSION_$ -* @copyright Copyleft -* @author $_SWANBR_AUTHOR_$ -* +------------------------------------------------------------------------------ -*/ - + * Kafka protocol since Kafka v0.8 + * +------------------------------------------------------------------------------ + * + * @package + * @version $_SWANBR_VERSION_$ + * @copyright Copyleft + * @author $_SWANBR_AUTHOR_$ + * +------------------------------------------------------------------------------ + */ class Consumer { - use \Psr\Log\LoggerAwareTrait; - use \Kafka\LoggerTrait; + use \Psr\Log\LoggerAwareTrait; + use \Kafka\LoggerTrait; - // {{{ consts - // }}} - // {{{ members - - private $isRunning = false; + // {{{ consts + // }}} + // {{{ members - // }}} - // {{{ functions - // {{{ public function __construct() + private $isRunning = false; - /** - * __construct - * - * @access public - * @param $hostList - * @param null $timeout - */ - public function __construct() - { - } + // }}} + // {{{ functions + // {{{ public function __construct() - // }}} - // {{{ public function start() + /** + * __construct + * + * @access public + * @param $hostList + * @param null $timeout + */ + public function __construct() + { + } - /** - * start consumer - * - * @access public - * @return void - */ - public function start(\Closure $consumer = null, $isBlock = true) - { - if ($this->isRunning) { - $this->error('Has start consumer'); - return; - } - $process = new \Kafka\Consumer\Process($consumer); - if ($this->logger) { - $process->setLogger($this->logger); - } - $process->start(); - $this->isRunning = true; - run(); - } + // }}} + // {{{ public function start() - // }}} - // }}} + /** + * start consumer + * + * @access public + * @return void + */ + public function start(\Closure $consumer = null, $isBlock = true) + { + if ($this->isRunning) { + $this->error('Has start consumer'); + return; + } + $process = new \Kafka\Consumer\Process($consumer); + if ($this->logger) { + $process->setLogger($this->logger); + } + $process->start(); + $this->isRunning = true; + if ($isBlock) { + run(); + } + } + + // }}} + // }}} }