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

Conversation

andreyddk
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?

The debug message of nats server is annoying and its cant be disabled.
DEBUG [Server] NatsStatus: type: "pingTimer", data: "1".

Issue Number: 10783

What is the new behavior?

My propose it is extends the implementation existed flag debug of MicroserviceOptions for disable pingTimer message.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Comment on lines 60 to 63
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;
}

@coveralls
Copy link

Pull Request Test Coverage Report for Build ba2623a9-72df-472a-80de-48f52028c6d2

  • 5 of 8 (62.5%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.03%) to 93.375%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/microservices/client/client-nats.ts 5 8 62.5%
Totals Coverage Status
Change from base Build 393e3dcf-e88a-4f3f-bc19-954133a0d73d: -0.03%
Covered Lines: 6202
Relevant Lines: 6642

💛 - Coveralls

@bittlerr
Copy link
Contributor

bittlerr commented Jan 9, 2023

@kamilmysliwiec what do you think of the solution @andreyddk provided?

@vdumbrav
Copy link

@kamilmysliwiec any news here?

@kamilmysliwiec
Copy link
Member

LGTM

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.

None yet

5 participants