改名
This commit is contained in:
+13
-14
@@ -14,19 +14,18 @@
|
||||
|
||||
namespace Kafka\Producer;
|
||||
|
||||
use Swoole\Timer;
|
||||
|
||||
/**
|
||||
* +------------------------------------------------------------------------------
|
||||
* 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 Process
|
||||
{
|
||||
use \Psr\Log\LoggerAwareTrait;
|
||||
@@ -111,13 +110,13 @@ class Process
|
||||
$config = \Kafka\ProducerConfig::getInstance();
|
||||
$isAsyn = $config->getIsAsyn();
|
||||
if (!$isAsyn) {
|
||||
Timer::tick($msInterval = $config->getRequestTimeout(), function ($watcherId) {
|
||||
\Amp\repeat(function ($watcherId) {
|
||||
if ($this->error) {
|
||||
call_user_func($this->error, 1000);
|
||||
}
|
||||
\Amp\cancel($watcherId);
|
||||
\Amp\stop();
|
||||
});
|
||||
}, $msInterval = $config->getRequestTimeout());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+18
-20
@@ -14,23 +14,21 @@
|
||||
|
||||
namespace Kafka\Producer;
|
||||
|
||||
use Swoole\Timer;
|
||||
|
||||
/**
|
||||
* +------------------------------------------------------------------------------
|
||||
* 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 State
|
||||
{
|
||||
use \Kafka\SingletonTrait;
|
||||
|
||||
// {{{ consts
|
||||
|
||||
const REQUEST_METADATA = 1;
|
||||
@@ -61,10 +59,10 @@ class State
|
||||
{
|
||||
$this->callStatus = array(
|
||||
self::REQUEST_METADATA => array(
|
||||
'status' => self::STATUS_LOOP,
|
||||
'status'=> self::STATUS_LOOP,
|
||||
),
|
||||
self::REQUEST_PRODUCE => array(
|
||||
'status' => self::STATUS_LOOP,
|
||||
'status'=> self::STATUS_LOOP,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -95,13 +93,13 @@ class State
|
||||
{
|
||||
foreach ($this->requests as $request => $option) {
|
||||
$interval = isset($option['interval']) ? $option['interval'] : 200;
|
||||
Timer::tick($msInterval = $interval, function ($watcherId) use ($request, $option) {
|
||||
\Amp\repeat(function ($watcherId) use ($request, $option) {
|
||||
if ($this->checkRun($request) && $option['func'] != null) {
|
||||
$context = call_user_func($option['func']);
|
||||
$this->processing($request, $context);
|
||||
}
|
||||
$this->requests[$request]['watcher'] = $watcherId;
|
||||
});
|
||||
}, $msInterval = $interval);
|
||||
}
|
||||
|
||||
// start sync metadata
|
||||
@@ -110,9 +108,9 @@ class State
|
||||
$context = call_user_func($this->requests[self::REQUEST_METADATA]['func']);
|
||||
$this->processing($request, $context);
|
||||
}
|
||||
Timer::tick($msInterval = 1000, function ($watcherId) {
|
||||
\Amp\repeat(function ($watcherId) {
|
||||
$this->report();
|
||||
});
|
||||
}, $msInterval = 1000);
|
||||
}
|
||||
|
||||
// }}}
|
||||
@@ -194,7 +192,7 @@ class State
|
||||
$this->callStatus = array(
|
||||
self::REQUEST_METADATA => $this->callStatus[self::REQUEST_METADATA],
|
||||
self::REQUEST_PRODUCE => array(
|
||||
'status' => self::STATUS_LOOP,
|
||||
'status'=> self::STATUS_LOOP,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user