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

[CHANGED] StreamInfo() will now return all subjects when requested #1072

Merged
merged 1 commit into from Sep 15, 2022

Conversation

jnmoyne
Copy link
Contributor

@jnmoyne jnmoyne commented Sep 9, 2022

If a subject filter is specified in the StreamInfoRequest{} option,
then all matching subjects will be returned and not be capped to
the server limit of 100,000. It is internally using pagination
that was added in the server PR: nats-io/nats-server#3454

Copy link
Member

@kozlovic kozlovic left a comment

Choose a reason for hiding this comment

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

At the very least you need to update go_test.mod to the latest version of the server so you can benefit from the feature you added in the server. But I think we can get away with reusing StreamInfo() as opposed to add a new function.

jsm.go Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Sep 13, 2022

Coverage Status

Coverage increased (+0.03%) to 85.565% when pulling 65796fc on jnm/implement_server_PR_3454 into 866ce08 on main.

go_test.mod Outdated Show resolved Hide resolved
jsm.go Outdated Show resolved Hide resolved
jsm.go Outdated Show resolved Hide resolved
jsm.go Outdated Show resolved Hide resolved
jsm.go Outdated Show resolved Hide resolved
@jnmoyne jnmoyne force-pushed the jnm/implement_server_PR_3454 branch 4 times, most recently from f8225dc to 200b836 Compare September 13, 2022 22:59
jsm.go Outdated Show resolved Hide resolved
jsm.go Outdated
}

for {
siOpts.Offset = i
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 changing the behavior in that it makes all StreamInfo request being a non empty request with an Offset (since I don't think this is omitempty). I would set a boolean in the "if" condition above that at least do the offset setting and marshal ONLY if the o.streamInfoOpts is not nil, or maybe rewrite in a way that you deal with simple info where no subject details is asked first, then deal with the cases where subjects are returned.

jsm.go Outdated
}

if subjectMessagesMap == nil {
subjectMessagesMap = make(map[string]uint64, total)
Copy link
Member

Choose a reason for hiding this comment

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

Technically, here even if user did not ask for details, you are now creating this map and returning as a resp.StreamInfo.State.Subjects (empty, but non nil map). More reasons maybe to treat the two situations differently, or at the very least do the creation only if map is nil AND the aforementioned boolean is set (indicating that we were asking for subject details)

If a subject filter is specified in the StreamInfoRequest{} option,
then all matching subjects will be returned and not be capped to
the server limit of 100,000. It is internally using pagination
that was added in the server PR: nats-io/nats-server#3454
@kozlovic kozlovic changed the title Implements a new jsm function StreamContainedSubjects() [CHANGED] StreamInfo() will now return all subjects when requested Sep 15, 2022
@kozlovic kozlovic merged commit 72a9635 into main Sep 15, 2022
@kozlovic kozlovic deleted the jnm/implement_server_PR_3454 branch September 15, 2022 22:50
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