-
Notifications
You must be signed in to change notification settings - Fork 150
Open
Description
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
-
Simplifying Connection Logic:
- Removing the loop for connection attempts and replacing it with a single connection attempt using NATS connection parameters such as
ReconnectWaitandMaxReconnects.
- Removing the loop for connection attempts and replacing it with a single connection attempt using NATS connection parameters such as
-
Improving Error Handling:
- Implementing NATS connection event handlers (
DisconnectErrHandler,ReconnectHandler, andClosedHandler) to provide detailed logs for connection lifecycle events.
- Implementing NATS connection event handlers (
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels