Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Closed
hilleer wants to merge 2 commits into confluentinc:master from hilleer:chore/list-producer-on-methods
Closed

[Typescript] chore: list producer "on" event methods by event name #267

hilleer wants to merge 2 commits into confluentinc:master from hilleer:chore/list-producer-on-methods

Conversation

@hilleer
Copy link

@hilleer hilleer commented Feb 28, 2025
edited
Loading

What

Accordingly to the producer standard API documentation there are event listener methods available on the Producer instance 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 on event emitter for the event names ready and event.error described in the documentation. There might be more events available?

Checklist

  • Contains customer facing changes? Including API/behavior changes
  • Did you add sufficient unit test and/or integration test coverage for this PR?
    • If not, please explain why it is not required

Test & Review

Open questions / Follow-ups

  • Are there any more event names to be listed?

@hilleer hilleer requested review from a team as code owners February 28, 2025 12:00
@hilleer hilleer changed the title (削除) chore: list producer on event methods (削除ここまで) (追記) [Typescript] chore: list producer on event methods (追記ここまで) Feb 28, 2025
@hilleer hilleer changed the title (削除) [Typescript] chore: list producer on event methods (削除ここまで) (追記) [Typescript] chore: list producer "on" event methods by event name (追記ここまで) Feb 28, 2025
Revert formatting change
Copy link
Contributor

milindl commented Mar 3, 2025

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.

hilleer reacted with confused emoji hilleer reacted with eyes emoji

Copy link
Author

hilleer commented Mar 3, 2025

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?

Copy link
Contributor

milindl commented Mar 5, 2025

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.

hilleer reacted with thumbs up emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /