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

Nats reconnection forever #1393

Closed
mojixcoder opened this issue Sep 10, 2023 · 1 comment · Fixed by #1394
Closed

Nats reconnection forever #1393

mojixcoder opened this issue Sep 10, 2023 · 1 comment · Fixed by #1394
Labels
proposal Enhancement idea or proposal

Comments

@mojixcoder
Copy link
Contributor

mojixcoder commented Sep 10, 2023

What motivated this proposal?

When I wanted to set the max number of Nats reconnections, at first, I noticed there is no clear way to tell Nats to try to reconnect to the Nats server forever.

After a few searches, I found out I could pass -1 to the nats.MaxReconnects to make it try to reconnect forever.

What is the proposed change?

There is no comment for the function nats.MaxReconnects, so if you want to find out how to make Nats try reconnections forever you have to google it and find the answer after a few searches.

I think it would be really nice to let the users know about this option in the comments because I think this a nice and important feature and would decrease confusion at first glance.

Another thing we can do is adding a new const for unlimited reconnections, like the nats.net library: public static int ReconnectForever = -1;.

The API would be something like this:

c, err := nats.Connect(address, nats.MaxReconnects(nats.ReconnectForever))

Who benefits from this change?

Confused people like me.

What alternatives have you evaluated?

No response

If this proposal is accepted I can submit a PR for that.

@mojixcoder mojixcoder added the proposal Enhancement idea or proposal label Sep 10, 2023
@wallyqs
Copy link
Member

wallyqs commented Sep 10, 2023

sounds good to update the comments at https://github.com/nats-io/nats.go/blob/main/nats.go#L948-L955 to show this usage, feel free to send PR.

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

Successfully merging a pull request may close this issue.

2 participants