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

feat(microservices): return all clients from kafka unwrap #14469

Conversation

kostyazgara
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #11616

While the new major release ships an ability to unwrap underlying server instance, it's still not possible to manipulate on existing consumer and producer instances which are created in start method. As an example provided in the issue, we still can't subscribe heartbeat event on consumer created by NestJS

What is the new behavior?

Following the example in Redis server, we can return all created instances, but not just client instance. In this case everyone can get an access to consumer and producers

Does this PR introduce a breaking change?

  • Yes
  • No

unwrap method is not type-safe and fully depend on developer who define expected type. If someone is already start using unwrap method we might get into the trouble of unexpected result and developer must change their expected type manually

const client = microservice.unwrap<Kafka>(); // old
const [client] = microservice.unwrap<[Kafka]>() // new

Other information

@coveralls
Copy link

Pull Request Test Coverage Report for Build a7d5ea97-fe6b-459e-b968-9201888555e4

Details

  • 0 of 1 (0.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 89.696%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/microservices/server/server-kafka.ts 0 1 0.0%
Totals Coverage Status
Change from base Build 328c39aa-d23d-4fdf-994c-d2c72f2f696a: 0.0%
Covered Lines: 7103
Relevant Lines: 7919

💛 - Coveralls

@kamilmysliwiec kamilmysliwiec merged commit 3c9f2ad into nestjs:master Jan 22, 2025
3 checks passed
@kostyazgara kostyazgara deleted the return-kafkajs-consumers-and-producers branch January 22, 2025 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants