-
Notifications
You must be signed in to change notification settings - Fork 9
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
Incorrect Kafka Initialization Example in README Causing TypeScript Error #225
Comments
Thanks for filing this! I'll probably make Regarding the other question, we have migrated most of what we targeted to migrate from KafkaJS. Depending on user feedback, we might consider some API additions or changes, but right now, this is pretty much it in terms of the migration. A few exceptions are the AdminAPI (we plan to add more of them), and certain configuration values (like the size of the batch in the eachBatch callback). Besides this, we won't migrate any future additions to the KafkaJS library (or node-rdkafka for that matter), and there are certain things we've chosen not to migrate (for example, the .on events). A more complete list is here: MIGRATION.md. |
Thank you so much for the quick response! 😊
I think making Would it be possible to mitigate this confusion by explicitly defining the minimum required fields or providing default values in the examples?
I am currently developing an application using Nest.js and KafkaJS. Part of this involves handling lifecycle events with Could you share the reasoning behind excluding this feature from the migration plan? Understanding the background would help us find better alternatives to adapt our application. 😊 |
Since we have different internals to KafkaJS, some of the raised events don't map onto our internal. Some require workarounds (just creating an event 'artificially'), and most of the events we can raise don't contain all the fields. So - given that this is public API which we rarely, if ever, remove, we decided against it. So far, the most common use we've seen requested is for rebalance/partition assignment, which is made available through the rebalance callback. What's your use case for the events, it's possible I'll be able to suggest ideas. |
Our project leverages the structure of the Kafka Client from @nestjs/microservices and applies KafkaJS Instrumentation Events in a similar way. While we do not utilize all Instrumentation Events, we rely on key events such as Connect and Rebalancing to log and monitor the state of Consumers and Producers, as well as to manage potential issues effectively. Additionally, we use the As you mentioned, tasks related to rebalancing can likely be addressed using the |
Environment Information
Overview
To connect to Kafka, the
class Kafka
from('@confluentinc/kafka-javascript').KafkaJS
is used to manage connections and create Producers and Consumers. However, incorrect initialization methods are presented in the README and some example codes, causing errors.Problematic Code
Extracted and slightly modified from the README and Confluent Kafka Node.js Client examples
Error Message
The
class Kafka
requiresCommonConstructorConfig
as a mandatory argument in its constructor. However, the examplesomit this argument, leading to errors.
Cause Analysis
CommonConstructorConfig
is a mandatory parameter that defines the detailed connection settings for the Kafka cluster. While omitting this argument does not cause issues in JavaScript, it results in a type error in TypeScript.Proposed Solutions
CommonConstructorConfig
Optional inclass Kafka
new Kafka({})
approach aligns with the philosophy of the library.
Additional Questions
The
confluent-kafka-javascript
library appears to be designed based onnode-rdkafka
andKafkaJS
. Is it a long-term goal to migrate all functionalities of KafkaJS into this library?The text was updated successfully, but these errors were encountered: