Skip to content

Commit 0dce70a

Browse files
authored
Merge pull request #1 from SepteniTechnology/feature/add_ssl_configuration
feature/add_ssl_configuration
2 parents 091d62a + 98a6393 commit 0dce70a

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

config/kafka.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,14 @@
33
return [
44
// Brokers address
55
'brokers' => array_filter(explode(',',env('KAFKA_BROKERS', ''))),
6+
'options' => [
7+
'log_level' => LOG_DEBUG,
8+
'debug' => 'all',
9+
'security.protocol' => 'ssl',
10+
'ssl.truststore.type' => 'JKS',
11+
'ssl.truststore.location' => env('KAFKA_SSL_TRUSTSTORE_LOCATION'),
12+
'ssl.truststore.password' => env('KAFKA_SSL_TRUSTSTORE_PASSWORD'),
13+
'ssl.keystore.location' => env('KAFKA_SSL_KEYSTORE_LOCATION'),
14+
'ssl.keystore.password' => env('KAFKA_SSL_KEYSTORE_PASSWORD')
15+
]
616
];

src/KafkaServerProvider.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,18 @@ public function register()
2121
});
2222

2323

24-
$this->app->singleton(RdKafka::class, function () {
24+
$this->app->singleton(RdKafka::class, function ($app) {
2525
$conf = new Conf();
26-
$conf->set('log_level', (string) LOG_DEBUG);
27-
$conf->set('debug', 'all');
26+
27+
$config = $app['config']->get('kafka');
28+
29+
$options = $config['options'] ?? [];
30+
foreach ($options as $option => $value) {
31+
$conf->set($option, $value);
32+
}
33+
34+
// $conf->set('log_level', (string) LOG_DEBUG);
35+
// $conf->set('debug', 'all');
2836
return new Producer($conf);
2937
});
3038

@@ -34,4 +42,4 @@ public function register()
3442
__DIR__ . '/../config/kafka.php' => config_path('kafka.php')
3543
], 'kafka');
3644
}
37-
}
45+
}

0 commit comments

Comments
 (0)