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

Improve nats Client Connection Logic #863

Open
sergeyWh1te opened this issue Jun 14, 2024 · 0 comments
Open

Improve nats Client Connection Logic #863

sergeyWh1te opened this issue Jun 14, 2024 · 0 comments

Comments

@sergeyWh1te
Copy link

Description

The current implementation of the nats NewClient function in codebase has a few areas that need improvement for better connection management and logging. The following issues have been identified:

Redundant Connection Attempts:
- The current implementation attempts to connect to the NATS server in a loop, retrying up to 10 times with a 1-second delay. This can lead to unnecessary retries and increased latency in establishing a connection.

Proposed Solution

  1. Simplifying Connection Logic:

    • Removing the loop for connection attempts and replacing it with a single connection attempt using NATS connection parameters such as ReconnectWait and MaxReconnects.
  2. Improving Error Handling:

    • Implementing NATS connection event handlers (DisconnectErrHandler, ReconnectHandler, and ClosedHandler) to provide detailed logs for connection lifecycle events.

#862

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant