改名
This commit is contained in:
+2
-2
@@ -31,7 +31,7 @@ class Producer extends Component
|
|||||||
private Conf $conf;
|
private Conf $conf;
|
||||||
private TopicConf $topicConf;
|
private TopicConf $topicConf;
|
||||||
|
|
||||||
private \RdKafka\Producer $producer;
|
private ?\RdKafka\Producer $producer = null;
|
||||||
|
|
||||||
|
|
||||||
public function __construct($config = [])
|
public function __construct($config = [])
|
||||||
@@ -96,7 +96,7 @@ class Producer extends Component
|
|||||||
$event = Snowflake::app()->getEvent();
|
$event = Snowflake::app()->getEvent();
|
||||||
$event->on(Event::EVENT_AFTER_REQUEST, [$this, 'flush']);
|
$event->on(Event::EVENT_AFTER_REQUEST, [$this, 'flush']);
|
||||||
|
|
||||||
if (!$this->producer) {
|
if ($this->producer === null) {
|
||||||
$this->producer = Snowflake::createObject(\RdKafka\Producer::class, [$this->conf]);
|
$this->producer = Snowflake::createObject(\RdKafka\Producer::class, [$this->conf]);
|
||||||
}
|
}
|
||||||
$topic = $this->producer->newTopic($this->_topic, $this->topicConf);
|
$topic = $this->producer->newTopic($this->_topic, $this->topicConf);
|
||||||
|
|||||||
Reference in New Issue
Block a user