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;
/**
+------------------------------------------------------------------------------
* +------------------------------------------------------------------------------
* Kafka Broker info manager
+------------------------------------------------------------------------------
* +------------------------------------------------------------------------------
*
* @package
* @version $_SWANBR_VERSION_$
* @copyright Copyleft
* @author $_SWANBR_AUTHOR_$
+------------------------------------------------------------------------------
* +------------------------------------------------------------------------------
*/
class Broker
{
use SingletonTrait;
// {{{ consts
// }}}
// {{{ members
@@ -194,6 +194,7 @@ class Broker
return $socket;
} catch (\Exception $e) {
$this->error($e->getMessage());
$this->error($e->getFile() . ':' . $e->getLine());
return false;
}
} else {
+21 -21
View File
@@ -243,27 +243,27 @@ class Socket
// stream_set_blocking($this->stream->getpeername(), 0);
// stream_set_read_buffer($this->stream, 0);
$this->readWatcher = \Amp\onReadable($this->stream, function () {
do {
try {
if (!$this->isSocketDead($this->stream)) {
$newData = $this->stream->recv(self::READ_MAX_LEN);
} else {
$this->reconnect();
return;
}
if ($newData) {
$this->read($newData);
}
} catch (\Exception $exception) {
var_dump($exception->getMessage());
}
} while ($newData);
});
$this->writeWatcher = \Amp\onWritable($this->stream, function () {
$this->write();
}, array('enable' => false)); // <-- let's initialize the watcher as "disabled"
// $this->readWatcher = \Amp\onReadable($this->stream, function () {
// do {
// try {
// if (!$this->isSocketDead($this->stream)) {
// $newData = $this->stream->recv(self::READ_MAX_LEN);
// } else {
// $this->reconnect();
// return;
// }
// if ($newData) {
// $this->read($newData);
// }
// } catch (\Exception $exception) {
// var_dump($exception->getMessage());
// }
// } while ($newData);
// });
//
// $this->writeWatcher = \Amp\onWritable($this->stream, function () {
// $this->write();
// }, array('enable' => false)); // <-- let's initialize the watcher as "disabled"
}
// }}}