-
Notifications
You must be signed in to change notification settings - Fork 26
feat(kafka-client): Allow for kafka client configuration to be passed through via CLI #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Added support for loading Kafka client configurations from a properties file via the CLI. - Enhanced CLI options to include a new `--kafka-config-file` argument for specifying the properties file path. - Refactored error handling in file reading functions to throw errors instead of exiting the process. - Updated the DefaultClientManager to merge configurations from the properties file with environment variables, improving flexibility in Kafka client setup. - Introduced a new utility function to parse properties files, enhancing configuration management.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for loading Kafka client configurations via a CLI-provided properties file, updates error handling to use thrown exceptions, and refactors the Kafka client manager to use a unified GlobalConfig
.
- Switched from
CommonConstructorConfig
toGlobalConfig
inindex.ts
and client manager, merging environment and CLI settings. - Introduced
--kafka-config-file
CLI option andparsePropertiesFile
utility for properties-file parsing. - Refactored file-reading utilities and CLI parsing helpers to throw errors instead of calling
process.exit
.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/index.ts | Use GlobalConfig and merge CLI-provided Kafka properties |
src/confluent/client-manager.ts | Refactor DefaultClientManager to accept GlobalConfig and build consumer config dynamically |
src/cli.ts | Add --kafka-config-file option, implement parsePropertiesFile , and replace exits with exceptions |
package.json | Add properties-file dependency |
Comments suppressed due to low confidence (2)
src/cli.ts:294
- [nitpick] New utility 'parsePropertiesFile' lacks unit tests; add tests to cover scenarios like missing file, parse errors, and successful parsing.
export function parsePropertiesFile(filePath: string): KeyValuePairObject {
src/confluent/client-manager.ts:229
- Passing a GlobalConfig object as the consumer configuration may be incompatible with KafkaJS.Consumer's expected configuration; consider using the ConsumerConfig type or mapping keys to the correct consumer config properties (e.g., groupId, fromBeginning).
return this.kafkaClient.get().consumer(consumerConfig);
closes #21 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the Kafka client configuration by integrating a new properties file-based configuration via the CLI, refactoring error handling, and migrating from KafkaJS.CommonConstructorConfig to GlobalConfig.
- Introduces a new CLI option (--kafka-config-file) that enables users to supply Kafka client configuration via a properties file.
- Replaces process exits with exceptions in file reading functions to improve error propagation.
- Refactors client and consumer creation by merging environment variable–based configurations with CLI-provided overrides.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/index.ts | Updates import and configuration merging for Kafka client setup. |
src/confluent/client-manager.ts | Adapts consumer and producer initialization to use GlobalConfig and removes hardcoded producer options. |
src/cli.ts | Adds support for Kafka config file CLI option, updates error handling logic. |
package.json | Adds dependency for the "properties-file" package. |
README.md | Updates documentation with the new CLI option description. |
} | ||
: {}), | ||
// Merge any additional properties from the kafka config file | ||
...cliOptions.kafkaConfig, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider clarifying the precedence of configuration merging between environment variables and CLI-provided Kafka configuration; ensure that CLI settings are intended to override environment variables as designed.
Copilot uses AI. Check for mistakes.
--kafka-config-file
argument for specifying the properties file path.This pull request introduces enhancements to the CLI and Kafka client configuration, improving flexibility and error handling. It adds support for loading Kafka configurations from a properties file, refactors Kafka configuration management, and replaces abrupt process exits with exceptions for better error propagation.
CLI Enhancements:
--kafka-config-file
option to the CLI, allowing users to specify a properties file for Kafka client configuration.parsePropertiesFile
function to read and parse properties files.Error Handling Improvements:
process.exit
calls with thrown exceptions in functions likereadFileLines
andloadEnvironmentVariables
, ensuring errors propagate properly.Kafka Configuration Refactor:
KafkaJS.CommonConstructorConfig
toGlobalConfig
for Kafka client configuration, aligning with a more flexible and standardized approach.compression.type
andlinger.ms
.Environment and Kafka Config Merging:
These changes enhance the flexibility and maintainability of the application while improving the user experience for configuring Kafka clients.