This commit is contained in:
2020-10-30 11:25:14 +08:00
parent aebfda74c6
commit 5473c0cad7
+2 -2
View File
@@ -31,7 +31,7 @@ class Producer extends Component
private Conf $conf;
private TopicConf $topicConf;
private \RdKafka\Producer $producer;
private ?\RdKafka\Producer $producer = null;
public function __construct($config = [])
@@ -96,7 +96,7 @@ class Producer extends Component
$event = Snowflake::app()->getEvent();
$event->on(Event::EVENT_AFTER_REQUEST, [$this, 'flush']);
if (!$this->producer) {
if ($this->producer === null) {
$this->producer = Snowflake::createObject(\RdKafka\Producer::class, [$this->conf]);
}
$topic = $this->producer->newTopic($this->_topic, $this->topicConf);