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

No responders #137

Merged
merged 5 commits into from
Oct 16, 2022
Merged

No responders #137

merged 5 commits into from
Oct 16, 2022

Conversation

mmmries
Copy link
Collaborator

@mmmries mmmries commented Oct 15, 2022

Resolves #136

The NATS server has the ability to send reply messages with a status of 503 when a message is sent to a topic with no subscribers. This is really handy for request-reply semantics so you can get an immediate error response rather than waiting for the receive_timeout to expire. Because this behavior is backwards incompatible, it must be opted into by the client.

I've written this PR assuming that we also want our users to opt into this behavior rather than making it the default, but I'm open to feedback on this point. Maybe we should default the no_responders: true after the next major version release?

If headers are enabled, and the user has passed in no_responders: true with their connection options, then the server will send back HMSG payloads with an empty body and a "503" status. In order to watch for this case in the code I also added parsing of the status and description from headers. Previously these have been ignored because I didn't know of a use-case for passing them back to the user, but I think it does make sense to provide this back to the user.

@mmmries
Copy link
Collaborator Author

mmmries commented Oct 15, 2022

@autodidaddict does this API make sense to you?

@autodidaddict
Copy link
Collaborator

To see if I've understood the API right, there's a new configuration option available in the connection settings when you start, called no_responders. By default it's disabled but if you enable it, then in addition to getting :timeout as a possible error from requests, you can also get an immediate :no_responders ?

If that's the case then it makes total sense

@mmmries
Copy link
Collaborator Author

mmmries commented Oct 16, 2022

Yes, that's exactly how the API is working. I'll add some docs (mind if I steal some of your description above?) and then we can release this as a minor version since it's totally opt-in

@mmmries mmmries merged commit 0cfb027 into main Oct 16, 2022
@mmmries mmmries deleted the no_responders branch October 16, 2022 20:04
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.

Quickly return for no responders
2 participants