This commit is contained in:
2020-10-09 17:41:05 +08:00
parent 2e345482aa
commit bbc77f69bc
2 changed files with 203 additions and 202 deletions
+5 -4
View File
@@ -15,20 +15,20 @@
namespace Kafka; namespace Kafka;
/** /**
+------------------------------------------------------------------------------ * +------------------------------------------------------------------------------
* Kafka Broker info manager * Kafka Broker info manager
+------------------------------------------------------------------------------ * +------------------------------------------------------------------------------
* *
* @package * @package
* @version $_SWANBR_VERSION_$ * @version $_SWANBR_VERSION_$
* @copyright Copyleft * @copyright Copyleft
* @author $_SWANBR_AUTHOR_$ * @author $_SWANBR_AUTHOR_$
+------------------------------------------------------------------------------ * +------------------------------------------------------------------------------
*/ */
class Broker class Broker
{ {
use SingletonTrait; use SingletonTrait;
// {{{ consts // {{{ consts
// }}} // }}}
// {{{ members // {{{ members
@@ -194,6 +194,7 @@ class Broker
return $socket; return $socket;
} catch (\Exception $e) { } catch (\Exception $e) {
$this->error($e->getMessage()); $this->error($e->getMessage());
$this->error($e->getFile() . ':' . $e->getLine());
return false; return false;
} }
} else { } else {
+21 -21
View File
@@ -243,27 +243,27 @@ class Socket
// stream_set_blocking($this->stream->getpeername(), 0); // stream_set_blocking($this->stream->getpeername(), 0);
// stream_set_read_buffer($this->stream, 0); // stream_set_read_buffer($this->stream, 0);
$this->readWatcher = \Amp\onReadable($this->stream, function () { // $this->readWatcher = \Amp\onReadable($this->stream, function () {
do { // do {
try { // try {
if (!$this->isSocketDead($this->stream)) { // if (!$this->isSocketDead($this->stream)) {
$newData = $this->stream->recv(self::READ_MAX_LEN); // $newData = $this->stream->recv(self::READ_MAX_LEN);
} else { // } else {
$this->reconnect(); // $this->reconnect();
return; // return;
} // }
if ($newData) { // if ($newData) {
$this->read($newData); // $this->read($newData);
} // }
} catch (\Exception $exception) { // } catch (\Exception $exception) {
var_dump($exception->getMessage()); // var_dump($exception->getMessage());
} // }
} while ($newData); // } while ($newData);
}); // });
//
$this->writeWatcher = \Amp\onWritable($this->stream, function () { // $this->writeWatcher = \Amp\onWritable($this->stream, function () {
$this->write(); // $this->write();
}, array('enable' => false)); // <-- let's initialize the watcher as "disabled" // }, array('enable' => false)); // <-- let's initialize the watcher as "disabled"
} }
// }}} // }}}