Skip to content

Commit fa01ae0

Browse files
author
Hamid Tavakoli
authored
Merge pull request #57 from topcoder-platform/feature/PLAT-1484
Format kafka url
2 parents 3c402ce + 3230d80 commit fa01ae0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/init.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,18 @@ const models = require('./models');
1616
async function configureKafkaConsumer(handlers) {
1717

1818
// create group consumer
19-
const options = { brokers: config.KAFKA_URL.split(',') };
19+
let brokers = ['']
20+
if (config.KAFKA_URL.startsWith('ssl://')) {
21+
brokers = config.KAFKA_URL.split('ssl://')[1].split(',')
22+
} else {
23+
brokers = config.KAFKA_URL.split(',')
24+
}
25+
const options = { brokers };
2026
if (config.KAFKA_CLIENT_CERT && config.KAFKA_CLIENT_CERT_KEY) {
2127
options.ssl = { cert: config.KAFKA_CLIENT_CERT, key: config.KAFKA_CLIENT_CERT_KEY };
2228
}
29+
30+
2331
const kafka = new Kafka(options)
2432
const consumer = kafka.consumer({ groupId: config.KAFKA_GROUP_ID });
2533
await consumer.connect()

0 commit comments

Comments
 (0)