This commit is contained in:
2020-10-28 11:52:34 +08:00
parent 3748efc6c8
commit 3b5c588eeb
2 changed files with 12 additions and 17 deletions
+12 -2
View File
@@ -56,9 +56,19 @@ class Kafka extends \Snowflake\Process\Process
public function onHandler(Process $process)
{
$this->channelListener();
$kafkaServers = SConfig::get('kafka');
var_dump(SConfig::get('kafka')[0]);
$this->waite(SConfig::get('kafka')[0]);
$waite = new WaitGroup();
foreach ($kafkaServers as $kafkaServer) {
$waite->add();
go(function () use ($kafkaServer, $waite) {
defer(function () use ($waite) {
$waite->done();
});
$this->waite($kafkaServer);
});
}
$waite->wait();
}
-15
View File
@@ -31,21 +31,6 @@ class KafkaProviders extends Providers
if (empty($kafka) || !($kafka['enable'] ?? false)) {
return;
}
if (!isset($kafka['topic']) || empty($kafka['topic'])) {
throw new Exception('kafka configure error.');
}
if (!isset($kafka['version']) || empty($kafka['version'])) {
throw new Exception('kafka configure error.');
}
if (!isset($kafka['brokers']) || empty($kafka['brokers'])) {
throw new Exception('kafka configure error.');
}
if (!isset($kafka['groupId']) || empty($kafka['groupId'])) {
throw new Exception('kafka configure error.');
}
if (!is_array($kafka['topics'])) {
throw new Exception('Add kafka topics must is array.');
}
$server->addProcess('kafka', Kafka::class);
}