改名
This commit is contained in:
+5
-10
@@ -109,22 +109,17 @@ class Producer extends Component
|
|||||||
$rk->flush($timeout);
|
$rk->flush($timeout);
|
||||||
|
|
||||||
$event = Snowflake::app()->getEvent();
|
$event = Snowflake::app()->getEvent();
|
||||||
$event->on(Event::EVENT_AFTER_REQUEST, function ($rk, $timeout) {
|
$event->on(Event::EVENT_AFTER_REQUEST, [$this,'onFlush'], [$rk, $timeout]);
|
||||||
var_dump(func_get_args());
|
|
||||||
}, [$rk, $timeout]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws NotFindClassException
|
* @param $rk
|
||||||
* @throws ReflectionException
|
* @param $timeout
|
||||||
*/
|
*/
|
||||||
public function onFlush()
|
public function onFlush($rk, $timeout)
|
||||||
{
|
{
|
||||||
/** @var \RdKafka\Producer $rk */
|
|
||||||
$rk = Snowflake::getDi()->get(\RdKafka\Producer::class);
|
|
||||||
|
|
||||||
$this->debug(Event::EVENT_AFTER_REQUEST);
|
$this->debug(Event::EVENT_AFTER_REQUEST);
|
||||||
$rk->flush(10);
|
$rk->flush($timeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -14,9 +14,9 @@ use Snowflake\Core\ArrayAccess;
|
|||||||
class Event extends BaseObject
|
class Event extends BaseObject
|
||||||
{
|
{
|
||||||
|
|
||||||
public $isVide = true;
|
public bool $isVide = true;
|
||||||
|
|
||||||
private $_events = [];
|
private array $_events = [];
|
||||||
|
|
||||||
const EVENT_ERROR = 'WORKER:ERROR';
|
const EVENT_ERROR = 'WORKER:ERROR';
|
||||||
const EVENT_STOP = 'WORKER:STOP';
|
const EVENT_STOP = 'WORKER:STOP';
|
||||||
@@ -191,6 +191,7 @@ class Event extends BaseObject
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
foreach ($this->_events[$name] as $event) {
|
foreach ($this->_events[$name] as $event) {
|
||||||
|
var_dump($event);
|
||||||
[$handler, $defaultParameter] = $event;
|
[$handler, $defaultParameter] = $event;
|
||||||
try {
|
try {
|
||||||
if (!empty($parameter)) {
|
if (!empty($parameter)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user