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

refactor(microservices): disable ping timer message in nats by flag #10798

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 5 additions & 7 deletions packages/microservices/client/client-nats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,11 @@ export class ClientNats extends ClientProxy {
this.logger.error(
`NatsError: type: "${status.type}", data: "${data}".`,
);
} else {
const message = `NatsStatus: type: "${status.type}", data: "${data}".`;
if (status.type === 'pingTimer') {
this.logger.debug(message);
} else {
this.logger.log(message);
}
}
if (status.type === 'pingTimer' && this.options.debug) {
this.logger.debug(
`NatsStatus: type: "${status.type}", data: "${data}".`,
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about errors not of type pingTimer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I missed it. I will fix it. What do you think about switch case for everyone status type? I guess its will be more clear for understanding about logic in handleStatusUpdates.

Example:

switch (status.type) {
  case 'error':
  case 'disconnect':
    this.logger.error(
      `NatsError: type: "${status.type}", data: "${data}".`
    );
    break;

  case 'pingTimer':
    if (this.options.debug) {
      this.logger.debug(
        `NatsStatus: type: "${status.type}", data: "${data}".`
      );
    }
    break;

  default:
    this.logger.log(
      `NatsStatus: type: "${status.type}", data: "${data}".`
    );
    break;
}

}
}
}
Expand Down