Skip to content

Commit

Permalink
update kafka client config
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscao633 committed Dec 18, 2024
1 parent 67164a7 commit 702be4e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
9 changes: 1 addition & 8 deletions scripts/check-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,5 @@ if (!process.env.SKIP_DB_CHECK && !process.env.DATABASE_TYPE) {
}

if (process.env.CLOUD_MODE) {
checkMissing([
'CLOUD_URL',
'KAFKA_BROKER',
'KAFKA_URL',
'REDIS_URL',
'KAFKA_SASL_MECHANISM',
'KAFKA_SSL',
]);
checkMissing(['CLOUD_URL', 'KAFKA_BROKER', 'KAFKA_URL', 'REDIS_URL', 'KAFKA_SASL_MECHANISM']);
}
5 changes: 3 additions & 2 deletions src/lib/kafka.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ const enabled = Boolean(process.env.KAFKA_URL && process.env.KAFKA_BROKER);
function getClient() {
const { username, password } = new URL(process.env.KAFKA_URL);
const brokers = process.env.KAFKA_BROKER.split(',');
const sslEnabled = process.env.KAFKA_SSL.toLowerCase() === 'true';
const mechanism = process.env.KAFKA_SASL_MECHANISM as 'plain' | 'scram-sha-256' | 'scram-sha-512';

const ssl: { ssl?: tls.ConnectionOptions | boolean; sasl?: SASLOptions } =
username && password
? {
ssl: sslEnabled,
ssl: {
rejectUnauthorized: false,
},
sasl: {
mechanism,
username,
Expand Down

0 comments on commit 702be4e

Please sign in to comment.