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

[ADDED] Add support for multi-get directly from a stream. #5107

Merged
merged 3 commits into from
Feb 27, 2024

Conversation

derekcollison
Copy link
Member

This allows a client to get multiple results based on multiple filters, each which can include a wildcard. You can optionally specify an UpToSeq or UpToTime.

The results will be returned in sequential order.

They will have headers matching direct get batch as well, with num pending being how many more results are coming. Currently we limit to 64 results maximum, and may revisit this in the future.

Signed-off-by: Derek Collison [email protected]

@derekcollison derekcollison requested a review from a team as a code owner February 19, 2024 22:51
@derekcollison derekcollison requested review from ripienaar, neilalexander and Jarema and removed request for a team February 19, 2024 22:51
Copy link
Contributor

@ripienaar ripienaar left a comment

Choose a reason for hiding this comment

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

Behaviour wise I find the batch/unbatched behaviour weird as pointed out in comments - it should just always be a batch imo.

To continue should we hit batch limits I think we need a bit more info.

Imagine I ask for USER.1234.> and this user has a ton of fields, more than 1000 or maxBytes, it would unexpectedly have to continue with another get to get the full user.

But how do I continue in a consistent way? I have no idea what the time or seq is to get it relative against?

So imagine if the EOB message included the sseq pass to UpToSeq for the next multi get.

In this case the sseq would be either the last message in the stream at the time that you gathered the seqs (as in the comment for MultiLastSeq in file store) or whatever the UpToSeq was or whatever UpToTime resolved the seq to. This way if there is a EOB and I need to get more keys to get the whole thing I immediately know that the next Multi get should have UpToSeq: sseq and all the many reads needed to resolve the entire USER.1234.> would be done around a consistent time.


// Multiple response support. Will get the last msgs matching the subjects. These can include wildcards.
MultiLastFor []string `json:"multi_last,omitempty"`
// Only return messages up to this sequence. If not set, will be last sequence for the stream.
Copy link
Contributor

Choose a reason for hiding this comment

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

worth clarifying that these following items are only aplicable to multi? Especially since the error Bad Request is opaque

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean more so that line 645?

}
}

sub := sendRequest(&JSApiMsgGetRequest{Seq: 1, MultiLastFor: []string{"foo.*"}})
Copy link
Contributor

Choose a reason for hiding this comment

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

why is Seq:1 required here when we are specifically asking for the last for subjects? Whats the seq being used for?

Copy link
Member Author

Choose a reason for hiding this comment

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

If it is a one-shot can be left alone and we start with 1, which is how far back should I look for a match. These is important one paged responses.

Copy link
Member Author

Choose a reason for hiding this comment

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

Got what you meant, will fix.

server/jetstream_test.go Show resolved Hide resolved
server/jetstream_test.go Show resolved Hide resolved
Copy link
Contributor

@ripienaar ripienaar left a comment

Choose a reason for hiding this comment

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

Behaviour wise this looks great, so LGTM. Minor comment on code, but get server team to review code.

server/jetstream_test.go Outdated Show resolved Hide resolved
@ripienaar
Copy link
Contributor

ADR update that attempts to capture the behaviour here nats-io/nats-architecture-and-design#268

This allows a client to get multiple results based on multiple filters, each which can include a wildcard.
You can optionally specify and UpToSeq or UpToTime.

The results will be returned in sequential order.

They will have headers matching direct get batch as well, with num pending being how many more results are coming.
Currently we limit to 64 results maximum, and may revisit this in the future.

Signed-off-by: Derek Collison <[email protected]>
Also made sure to honor MaxBytes and Batch same as direct get batch.

Left this here for easier comparison but will squash when merging.

Signed-off-by: Derek Collison <[email protected]>
…me UpToSeq even if it was not set on original request.

Also removed need for Seq to be set on simple multi-requests.

Signed-off-by: Derek Collison <[email protected]>
@derekcollison derekcollison merged commit 6e86d8a into main Feb 27, 2024
4 checks passed
@derekcollison derekcollison deleted the multi-get branch February 27, 2024 16:20
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.

2 participants