-
Notifications
You must be signed in to change notification settings - Fork 23
[Typescript] chore: list producer "on" event methods by event name #267
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
[Typescript] chore: list producer "on" event methods by event name #267
Conversation
Revert formatting change
Hey @hilleer , the 'on' methods aren't supported on the promisified producer (which is typed in kafkajs.d.ts). The documentation you've attached is from the "Callback-Based API" section, which is typed in rdkafka.d.ts, where there are typings for the events and Producer indirectly extends EventEmitter.
Hey @hilleer , the 'on' methods aren't supported on the promisified producer (which is typed in kafkajs.d.ts). The documentation you've attached is from the "Callback-Based API" section, which is typed in rdkafka.d.ts, where there are typings for the events and Producer indirectly extends EventEmitter.
So we are considering the promisified API to work fully in sequential order and have no need for event listeners here?
Right, we're attempting to do that. For instance, if you await producer.connect(), it's actually internally using the same 'ready' event, so the waiting ends only when the producer is ready. Similarly, awaited methods throw/reject if there's an error.
There are some exceptions at the moment, for instance, for the consumer rebalances, you need to use a rebalance callback within the config. But, for the most part, you should be able to use the API in sequential order.
Uh oh!
There was an error while loading. Please reload this page.
What
Accordingly to the producer standard API documentation there are event listener methods available on the
Producerinstance but those are not currently listed in the typings, making it difficult to find programmatically as well as showing typescript type errors:Property 'on' does not exist on type 'Producer'.ts(2339):Screenshot 2025年02月28日 at 13 02 55
From the docs:
Screenshot 2025年02月28日 at 13 02 20
Screenshot 2025年02月28日 at 13 02 24
This pull-request adds type definitions for the
onevent emitter for the event namesreadyandevent.errordescribed in the documentation. There might be more events available?Checklist
Test & Review
Open questions / Follow-ups