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

ADR-47 Request Many #228

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open

ADR-47 Request Many #228

wants to merge 25 commits into from

Conversation

scottf
Copy link
Collaborator

@scottf scottf commented Jun 27, 2023

Request Many ADR based on @aricart's implementation and discussion in #215

adr/ADR-40.md Outdated Show resolved Hide resolved
adr/ADR-40.md Outdated Show resolved Hide resolved
adr/ADR-40.md Outdated Show resolved Hide resolved
adr/ADR-40.md Outdated Show resolved Hide resolved
Copy link
Member

@aricart aricart left a comment

Choose a reason for hiding this comment

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

LGTM

adr/ADR-40.md Outdated Show resolved Hide resolved
@Jarema

This comment was marked as outdated.

Signed-off-by: Tomasz Pietrek <[email protected]>
@ripienaar

This comment was marked as outdated.

@Jarema
Copy link
Member

Jarema commented Jul 22, 2024

@ripienaar agree.
If we agree to put it in Orbit, we are IMO totally fine having more advanced & opinionated strategies like in this ADR.

@scottf scottf changed the title [new] ADR-40 Request Many ADR-47 Request Many Sep 26, 2024
@nats-io nats-io deleted a comment from Jarema Sep 26, 2024
@nats-io nats-io deleted a comment from aricart Sep 26, 2024

The maximum number of messages to wait for.
* Optional
* If this number of messages is received, the request is complete.
Copy link
Member

Choose a reason for hiding this comment

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

seems implementation is leaning towards sub inbox per request so this should be using auto unsub here

Copy link
Member

Choose a reason for hiding this comment

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

This is a great idea, but would work only on non-muxed request-many's.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Adding notes about the optionally using immediate unsub when max responses is supplied.

Copy link
Member

Choose a reason for hiding this comment

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

I see, ok it would be better if the muxed version of request for many responses is the one that is in the library since that has more value added and trickier to get right. Not sure if want to include both implementations (new style + old style) could be that just document that old style approach since not a lot of code in the ADR.

Copy link
Collaborator Author

@scottf scottf Oct 3, 2024

Choose a reason for hiding this comment

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

Is there a significant performance gain that would compensate for the complexity of using muxed?

Copy link
Member

Choose a reason for hiding this comment

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

the muxed version is better for the interest graph in cluster setups, specially in a super cluster setup with gateways, that is why clients Request defaults to that version

adr/ADR-47.md Outdated
If the client supports a sentinel with a callback/predicate that accepts the message and returns a boolean,
a return of true would mean continue to process and false would mean stop processing.

If possible, the client should support the "standard sentienl", which is a message with a null/nil or empty payload.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
If possible, the client should support the "standard sentienl", which is a message with a null/nil or empty payload.
If possible, the client should support the "standard sentinel", which is a message with a null/nil or empty payload.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

Copy link
Member

@MauriceVanVeen MauriceVanVeen left a comment

Choose a reason for hiding this comment

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

LGTM

adr/ADR-47.md Outdated

### Cancelling

If possible, the user should be able to cancel the request. This is not the sentinel.
Copy link
Member

Choose a reason for hiding this comment

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

here for example would mean to unsub without a limit set

Copy link
Collaborator Author

@scottf scottf Oct 3, 2024

Choose a reason for hiding this comment

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

This is intended that the dev can cancel the entire request-many arbitrarily. For instance I could envision a request that gives 1 second for responses, gets many, realizes it has all the information it needs and is done. If it's using a manual sentinel pattern with a predicate, they can short circuit that way, but if they are not using a sentinel, this is just another way for manually short circuit.

I will refine the section.


### Max messages

The maximum number of messages to wait for.
Copy link
Member

Choose a reason for hiding this comment

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

Depending on the implementation approach, with new style and max responses traffic wise you can get more than the max responses anyway and the client will receive them and not process them. With old style and auto unsub you can short circuit the number of max messages to avoid flooding the client with unnecessary responses, some pros and cons depending on the protocols sent.
New style/mux based approach has more value added though since more difficult to maintain for users on their own.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added more notes under a Max Responses Optimization section.

Theoretically this unsub could be processed after a reply has come in and out of the server, so you still must check the count manually.

### Best Practice
Since the client is in charge of the subscription, it should always unsubscribe upon completion of the request handling instead of leaving it up to the server to time it out.
Copy link
Member

Choose a reason for hiding this comment

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

would only happen when not using the mux version/new style, if using old style/non mux it must always clean up to avoid leaking subscriptions, that is a very common issue when users implement their own version of request/response expecting multiple responses

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.

9 participants