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

Can not override the KafkaServer constructor #5599

Closed
smhmayboudi opened this issue Oct 23, 2020 · 2 comments
Closed

Can not override the KafkaServer constructor #5599

smhmayboudi opened this issue Oct 23, 2020 · 2 comments
Labels
needs triage This issue has not been looked into

Comments

@smhmayboudi
Copy link
Contributor

smhmayboudi commented Oct 23, 2020

Bug Report

Current behavior

I want to rewrite KafkaServer. The option is private.

Input Code

https://github.com/nestjs/nest/blob/master/packages/microservices/server/server-kafka.ts#L45

import {
  KAFKA_DEFAULT_CLIENT,
  KAFKA_DEFAULT_GROUP,
} from "@nestjs/microservices/constants";
import { KafkaOptions, ServerKafka } from "@nestjs/microservices";

import { KafkaConfig } from "@nestjs/microservices/external/kafka-options.interface";

export class AppServerKafka extends ServerKafka {
  constructor(protected readonly options: KafkaOptions["options"]) {
    super(options);
    const clientOptions =
      // eslint-disable-next-line @typescript-eslint/ban-ts-comment
      // @ts-ignore
      this.getOptionsProp(this.options, "client") || ({} as KafkaConfig);
    this.clientId =
      // eslint-disable-next-line @typescript-eslint/ban-ts-comment
      // @ts-ignore
      // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
      (clientOptions.clientId || KAFKA_DEFAULT_CLIENT) + "_SERVER";
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
    this.groupId = (consumerOptions.groupId || KAFKA_DEFAULT_GROUP) + "_SERVER";
  }
}

Expected behavior

It should be protected.

Possible Solution

constructor(private readonly options: KafkaOptions['options']) {

should be change to

constructor(protected readonly options: KafkaOptions['options']) {

Environment


Nest version: 7.5.1

 
For Tooling issues:
- Node version: v12.19.0  
- Platform:  Mac

Others:

@smhmayboudi smhmayboudi added the needs triage This issue has not been looked into label Oct 23, 2020
@kamilmysliwiec
Copy link
Member

Would you like to create a PR for this issue?

@kamilmysliwiec
Copy link
Member

Fixed in 7.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue has not been looked into
Projects
None yet
Development

No branches or pull requests

2 participants