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

Make lookupStreamBySubject public #1114

Merged
merged 8 commits into from Oct 31, 2022
Merged

Conversation

Jarema
Copy link
Member

@Jarema Jarema commented Oct 28, 2022

Working on DAPR adapter for NATS (dapr/components-contrib#2161), I want to move from creating a Consumer by calling js.Subscribe() to explicit js.AddConsumer to avoid some errors.

Was surprised that this method is not public.

Signed-off-by: Jarema <melgaer@gmail.com>
@coveralls
Copy link

coveralls commented Oct 28, 2022

Coverage Status

Coverage increased (+0.02%) to 85.751% when pulling a1ff370 on jarema/make-subject-lookup-public into 6e4828a on main.

Signed-off-by: Jarema <melgaer@gmail.com>
js.go Outdated Show resolved Hide resolved
js_test.go Outdated Show resolved Hide resolved
js.go Outdated Show resolved Hide resolved
jsm.go Outdated Show resolved Hide resolved
js_test.go Outdated Show resolved Hide resolved
@Jarema Jarema requested a review from piotrpio October 28, 2022 13:32
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.

I think that the new API need to conform to others and accept []jSOpt. What do you think?

jsm.go Outdated
@@ -1515,6 +1518,31 @@ func (jsc *js) StreamNames(opts ...JSOpt) <-chan string {
return ch
}

// StreamNameBySubject returns a stream name that matches the subject.
func (jsc *js) StreamNameBySubject(subj string) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure this is right. Since this becomes a context level API, should you pass the js options as a vararg? Then inside you would call getJSContextOpts(), etc... User should be able to override the wait and apiSubj() still need fixing to make sure it uses any user domain provided override (granted not part of this PR).

Copy link
Collaborator

Choose a reason for hiding this comment

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

While I'm not a huge fan of the concept of having 1 common option type for all interface methods, in this case I agree. It makes sense to allow user to at least pass context/wait and be consistent with the rest of the interface at the same time.

Copy link
Member Author

Choose a reason for hiding this comment

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

agree. Updated the signature, and used jsc.apiRequestWithContext to at least use the context that can be passed, but still, it's misleading to give the user option to pass Domain and ApiPrefix and not use it.
That's consistent and I agree to have it, but it only adds up to what #1104 refers to.

Signed-off-by: Jarema <melgaer@gmail.com>
Copy link
Collaborator

@piotrpio piotrpio left a comment

Choose a reason for hiding this comment

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

LGTM

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.

LGTM

@piotrpio piotrpio merged commit 7ac1087 into main Oct 31, 2022
@piotrpio piotrpio deleted the jarema/make-subject-lookup-public branch October 31, 2022 15:30
@piotrpio piotrpio mentioned this pull request Nov 5, 2022
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

4 participants