改名
This commit is contained in:
@@ -73,9 +73,6 @@ class Consumer
|
|||||||
}
|
}
|
||||||
$process->start();
|
$process->start();
|
||||||
$this->isRunning = true;
|
$this->isRunning = true;
|
||||||
if ($isBlock) {
|
|
||||||
\Amp\run();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
|
|||||||
@@ -136,13 +136,13 @@ class State
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$interval = isset($option['interval']) ? $option['interval'] : 200;
|
$interval = isset($option['interval']) ? $option['interval'] : 200;
|
||||||
\Amp\repeat(function ($watcherId) use ($request, $option) {
|
Timer::tick($msInterval = $interval, function ($watcherId) use ($request, $option) {
|
||||||
if ($this->checkRun($request) && $option['func'] != null) {
|
if ($this->checkRun($request) && $option['func'] != null) {
|
||||||
$context = call_user_func($option['func']);
|
$context = call_user_func($option['func']);
|
||||||
$this->processing($request, $context);
|
$this->processing($request, $context);
|
||||||
}
|
}
|
||||||
$this->requests[$request]['watcher'] = $watcherId;
|
$this->requests[$request]['watcher'] = $watcherId;
|
||||||
}, $msInterval = $interval);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// start sync metadata
|
// start sync metadata
|
||||||
@@ -150,9 +150,9 @@ class State
|
|||||||
$context = call_user_func($this->requests[self::REQUEST_METADATA]['func']);
|
$context = call_user_func($this->requests[self::REQUEST_METADATA]['func']);
|
||||||
$this->processing($request, $context);
|
$this->processing($request, $context);
|
||||||
}
|
}
|
||||||
\Amp\repeat(function ($watcherId) {
|
Timer::tick($msInterval = 1000, function ($watcherId) {
|
||||||
$this->report();
|
$this->report();
|
||||||
}, $msInterval = 1000);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
|
|||||||
+10
-12
@@ -15,17 +15,16 @@
|
|||||||
namespace Kafka;
|
namespace Kafka;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
+------------------------------------------------------------------------------
|
* +------------------------------------------------------------------------------
|
||||||
* Kafka broker socket
|
* Kafka broker socket
|
||||||
+------------------------------------------------------------------------------
|
* +------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* @package
|
* @package
|
||||||
* @version $_SWANBR_VERSION_$
|
* @version $_SWANBR_VERSION_$
|
||||||
* @copyright Copyleft
|
* @copyright Copyleft
|
||||||
* @author $_SWANBR_AUTHOR_$
|
* @author $_SWANBR_AUTHOR_$
|
||||||
+------------------------------------------------------------------------------
|
* +------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Socket
|
class Socket
|
||||||
{
|
{
|
||||||
// {{{ consts
|
// {{{ consts
|
||||||
@@ -78,7 +77,7 @@ class Socket
|
|||||||
/**
|
/**
|
||||||
* Stream resource
|
* Stream resource
|
||||||
*
|
*
|
||||||
* @var mixed
|
* @var \Swoole\Coroutine\Socket
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
private $stream = null;
|
private $stream = null;
|
||||||
@@ -228,18 +227,16 @@ class Socket
|
|||||||
throw new \Kafka\Exception('Cannot open without port.');
|
throw new \Kafka\Exception('Cannot open without port.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->stream = @fsockopen(
|
$this->stream = new \Swoole\Coroutine\Socket(AF_INET, SOCK_STREAM);;
|
||||||
|
|
||||||
|
if (!$this->stream->connect(
|
||||||
$this->host,
|
$this->host,
|
||||||
$this->port,
|
$this->port,
|
||||||
$errno,
|
|
||||||
$errstr,
|
|
||||||
$this->sendTimeoutSec + ($this->sendTimeoutUsec / 1000000)
|
$this->sendTimeoutSec + ($this->sendTimeoutUsec / 1000000)
|
||||||
);
|
)) {
|
||||||
|
|
||||||
if ($this->stream == false) {
|
|
||||||
$error = 'Could not connect to '
|
$error = 'Could not connect to '
|
||||||
. $this->host . ':' . $this->port
|
. $this->host . ':' . $this->port
|
||||||
. ' ('.$errstr.' ['.$errno.'])';
|
. ' (' . $this->stream->errMsg . ' [' . $this->stream->errCode . '])';
|
||||||
throw new \Kafka\Exception($error);
|
throw new \Kafka\Exception($error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,6 +299,7 @@ class Socket
|
|||||||
// {{{ public function SetOnReadable()
|
// {{{ public function SetOnReadable()
|
||||||
|
|
||||||
public $onReadable;
|
public $onReadable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set on readable callback function
|
* set on readable callback function
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user