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

handle no responders in NatsSubBase #277

Merged
merged 7 commits into from
Dec 12, 2023
Merged

handle no responders in NatsSubBase #277

merged 7 commits into from
Dec 12, 2023

Conversation

caleblloyd
Copy link
Contributor

Handles No Responders in NatsSubBase, pre-de-serialization

Also handles StopOnEmptyMsg

This prevents the library from ever needing to check msg.Data for an Empty value

Signed-off-by: Caleb Lloyd <caleb@synadia.com>
@caleblloyd caleblloyd requested a review from mtmk December 8, 2023 15:52
@caleblloyd caleblloyd mentioned this pull request Dec 8, 2023
@caleblloyd
Copy link
Contributor Author

@mtmk let me know if you prefer this approach - then we can fix/add tests here

@stebet
Copy link
Contributor

stebet commented Dec 9, 2023

Does this impþementation kill the subscription? It's important in my opinion that the subscription be left intact for custom implementations of request-reply. My use case for example needs the subscription to stay intact for performance reasons (avoids the overhead of a new inbox + subscription for every request).

@caleblloyd
Copy link
Contributor Author

Does this impþementation kill the subscription?

Yes. But you can explicitly set NatsSubOpts.ThrowIfNoResponders=false and perform the check for a 503 code in the headers yourself.

@caleblloyd
Copy link
Contributor Author

Note that Request-Reply uses the muxed Inbox Subscription by default, which muxes all subscriptions over a single persistent NATS Subscription. So there's no additional NATS Subscription overhead on Inbox Subscriptions (except for the first one established).

@mtmk
Copy link
Collaborator

mtmk commented Dec 11, 2023

I'm mainly concerned about auto unsubs. especially empty message check silently unsubs which could be source of hard to find bugs. also no-responders check may be OK but that only happens on reply inbox subscriptions and not all subscriptions.

@mtmk
Copy link
Collaborator

mtmk commented Dec 11, 2023

If you chose to implement this feel free to get rid of #275

@caleblloyd
Copy link
Contributor Author

I'm mainly concerned about auto unsubs. especially empty message check silently unsubs which could be source of hard to find bugs. also no-responders check may be OK but that only happens on reply inbox subscriptions and not all subscriptions.

Both StopOnEmptyMsg? and ThrowIfNoResponders? are opt-in on NatsSubOpts. So nothing changes on normal subscriptions. For Request-Reply, ThrowIfNoResponders is set to true if not explicitly set to false, and if RequestMany is used then StopOnEmptyMsg is set to true if not explicitly set to false.

I think this matches all of the previous behavior.

@mtmk mtmk mentioned this pull request Dec 12, 2023
Signed-off-by: Caleb Lloyd <caleb@synadia.com>
Signed-off-by: Caleb Lloyd <caleb@synadia.com>
Signed-off-by: Caleb Lloyd <caleb@synadia.com>
@caleblloyd
Copy link
Contributor Author

Should be ready for review

Copy link
Collaborator

@mtmk mtmk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few nits

src/NATS.Client.Core/NatsConnection.RequestReply.cs Outdated Show resolved Hide resolved
src/NATS.Client.Core/NatsConnection.RequestReply.cs Outdated Show resolved Hide resolved
src/NATS.Client.Core/NatsSubBase.cs Outdated Show resolved Hide resolved
src/NATS.Client.Core/NatsSubOpts.cs Show resolved Hide resolved
Signed-off-by: Caleb Lloyd <caleb@synadia.com>
Signed-off-by: Caleb Lloyd <caleb@synadia.com>
Signed-off-by: Caleb Lloyd <caleb@synadia.com>
Copy link
Collaborator

@mtmk mtmk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mtmk
Copy link
Collaborator

mtmk commented Dec 12, 2023

Thank you @caleblloyd! was there any other change you wanted to make before merge?

@caleblloyd caleblloyd merged commit e662bdd into main Dec 12, 2023
9 checks passed
@caleblloyd caleblloyd deleted the caleb/no-responders branch December 12, 2023 20:38
@caleblloyd
Copy link
Contributor Author

Nope- just merged!

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

Successfully merging this pull request may close these issues.

None yet

3 participants