Skip to content

Commit

Permalink
ssal config added
Browse files Browse the repository at this point in the history
  • Loading branch information
piyal-ict-mbstu committed Sep 11, 2022
1 parent 121befa commit 4c71daa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/KafkaLogHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected function write(array $record): void
topic: $this->topic,
broker: $this->brokers
);
if (!empty($this->config['sasl_config'])) {
if ($this->config['is_sasl_apply'] && !empty($this->config['sasl_config'])) {
$kafka->withSasl(new Sasl(
username: $this->config['sasl_config']['username'],
password: $this->config['sasl_config']['password'],
Expand Down
2 changes: 2 additions & 0 deletions src/KafkaLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public static function getInstance(string $topicName, string $brokers, array $op
*/
public function __invoke(array $config): Logger
{

$logger = new Logger('kafka');
throw_if(empty($config['brokers']), new \Exception('Brokers is provided', ResponseAlias::HTTP_UNPROCESSABLE_ENTITY));
throw_if($config['is_sasl_apply'] && empty($config['sasl_config']), new \Exception('SASL Configuration is required', ResponseAlias::HTTP_UNPROCESSABLE_ENTITY));
Expand All @@ -52,6 +53,7 @@ public function __invoke(array $config): Logger
throw_if(empty($config['sasl_config']['mechanisms']), new \Exception('Auth Mechanisms is invalid', ResponseAlias::HTTP_UNPROCESSABLE_ENTITY));
throw_if(empty($config['sasl_config']['security_protocol']), new \Exception('SecurityProtocol is invalid', ResponseAlias::HTTP_UNPROCESSABLE_ENTITY));
}

$topic = $config['topic'];
$brokers = $config['brokers'];
$key = $config['key'] ?? config('app.name');
Expand Down

0 comments on commit 4c71daa

Please sign in to comment.