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

ClientKafka and KafkaServer naming conventions become much simpler #5603

Closed
smhmayboudi opened this issue Oct 25, 2020 · 4 comments
Closed
Labels
needs triage This issue has not been looked into type: enhancement 🐺

Comments

@smhmayboudi
Copy link
Contributor

Feature Request

Is your feature request related to a problem? Please describe.

"Kafka client and consumer naming conventions can be customized by extending ClientKafka and KafkaServer in your own custom provider and overriding the constructor."

Customizing a name becomes very complex since it can be solved with Kafka options.

Describe the solution you'd like

Adding two string to Kafka options and use them in ServerKafka and ClientKafka. Since those values are optional, there is no drawback but it saves a lot of code and effort.

Teachability, Documentation, Adoption, Migration Strategy

https://github.com/nestjs/nest/blob/master/packages/microservices/interfaces/microservice-configuration.interface.ts

export interface KafkaOptions {
  transport?: Transport.KAFKA;
  options?: {
     clientIdPostfix?: string;
     serverIdPostfix?: string;
     ...
  }
}

https://github.com/nestjs/nest/blob/master/packages/microservices/client/client-kafka.ts

    this.clientId =
      (clientOptions.clientId || KAFKA_DEFAULT_CLIENT) + (clientOptions.clientIdPostfix || '-client');
    this.groupId = (consumerOptions.groupId || KAFKA_DEFAULT_GROUP) + (clientOptions.clientIdPostfix || '-client');

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

    this.clientId =
      (clientOptions.clientId || KAFKA_DEFAULT_CLIENT) + (clientOptions.serverIdPostfix || '-server');
    this.groupId = (consumerOptions.groupId || KAFKA_DEFAULT_GROUP) + (clientOptions.serverIdPostfix || '-server');

What is the motivation / use case for changing the behavior?

I am using Kafka as my backbone of event-driven microservice and I use '_' instead of '-' in the patterns.

@smhmayboudi smhmayboudi added needs triage This issue has not been looked into type: enhancement 🐺 labels Oct 25, 2020
@kamilmysliwiec
Copy link
Member

Would you like to create a PR for this issue?

@smhmayboudi
Copy link
Contributor Author

I find out, I can do it just with one variable as clinetId.

More importantly, why Kafka interface is copied in two places.
nest/packages/common/interfaces/external/kafka.interface.ts
nest/packages/microservices/external/kafka.interface.ts

@kamilmysliwiec
Copy link
Member

Fixed in 7.5.0

@sgentile
Copy link

I'm specifying a group-id and it's appending client and server to it - they need to be the same so why is the library appending values that I didn't specify ?

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 type: enhancement 🐺
Projects
None yet
Development

No branches or pull requests

3 participants