This commit is contained in:
2020-10-28 16:30:01 +08:00
parent 13e46ea86a
commit 6fda19d2bc
+8 -6
View File
@@ -108,18 +108,20 @@ class Producer extends Component
$rk->poll($timeout); $rk->poll($timeout);
$event = Snowflake::app()->getEvent(); $event = Snowflake::app()->getEvent();
$event->on(Event::EVENT_AFTER_REQUEST, [$this, 'onFlush'], [$rk, $timeout]); $event->on(Event::EVENT_AFTER_REQUEST, [$this, 'onFlush']);
} }
/** /**
* @param $rk * @throws NotFindClassException
* @param $timeout * @throws ReflectionException
*/ */
public function onFlush($rk, $timeout) public function onFlush()
{ {
var_dump(func_get_args()); /** @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($timeout); $rk->flush(10);
} }
} }