Skip to content
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

Consumer inside KafkaPubSub class is private #26

Open
gnpace opened this issue Oct 13, 2023 · 2 comments
Open

Consumer inside KafkaPubSub class is private #26

gnpace opened this issue Oct 13, 2023 · 2 comments

Comments

@gnpace
Copy link

gnpace commented Oct 13, 2023

The consumer inside the KafkaPubSub class is private.

I need to access it in order to register it to some emitted events like "consumer.stop" or "consumer.crash".

Can you please provide a solution for this?

Maybe a public method inside the KafkaPubSub class that allows registering events to the created consumer could be a solution?

Thanks!

@gnpace
Copy link
Author

gnpace commented Oct 13, 2023

@tomasAlabes something like this could be a solution?

import {
  ...
  ConsumerEvents
  RemoveInstrumentationEventListener,
  ValueOf
} from "kafkajs";

...

public consumerOn(
  eventName: ValueOf<ConsumerEvents>,
  listener: (event: any) => void
): RemoveInstrumentationEventListener<typeof eventName> {
  return this.consumer.on(eventName, listener);
}

@tomasAlabes
Copy link
Owner

Would you mind create a PR for the proposal? I don't mind taking a look and adding it.

javi11 added a commit to javi11/graphql-kafkajs-subscriptions that referenced this issue Nov 3, 2023
Closes Consumer inside KafkaPubSub class is private tomasAlabes#26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants