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] option to not create durable on subscribe #734

Closed
wants to merge 9 commits into from

Conversation

matthiashanel
Copy link
Contributor

@matthiashanel matthiashanel commented May 24, 2021

Signed-off-by: Matthias Hanel mh@synadia.com

When exporting/importing say the next subject, the consumer exists already and does not need to be created.
Thus the client should also not try to look it up.

We went down the road of a don't create durable option (1st commit) but altered it to have a dedicated JS create call.
We believe that using BindJetStream might be easier to explain

Signed-off-by: Matthias Hanel <mh@synadia.com>
@coveralls
Copy link

coveralls commented May 24, 2021

Coverage Status

Coverage decreased (-0.3%) to 86.685% when pulling 9322734 on no-dur-create into 3b1f6fc on master.

Signed-off-by: Matthias Hanel <mh@synadia.com>
js.go Outdated Show resolved Hide resolved
Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

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

Help me understand when this option would be used?

@matthiashanel
Copy link
Contributor Author

@derekcollison This new call would be used whenever you don't want the client to create durables/streams automagically.
This will help with export/import or when you have restrictive permissions

@derekcollison
Copy link
Member

I guess that is what I was looking for clarity on since now we bind to existing durables if they exist and don't always create them, so wanted to make sure I understood the difference in this case.

@matthiashanel
Copy link
Contributor Author

if you call JetStream then consumer etc will be created.
if you call BindJetStream we assume they exist.

I can add an exception if no durable name was provided an an ephemeral durable needs creating.
comments? @wallyqs

@derekcollison
Copy link
Member

When is their a case where you can to have a durable option like we do now but not create?

This because in those situations you do not want the client lib doing its probing to see which direction it should go with a durable etc?

@matthiashanel
Copy link
Contributor Author

matthiashanel commented May 25, 2021

Exactly, when I only export the next subject or have restrictive permissions I want to avoid probing around, as this would fail.

js.go Show resolved Hide resolved
Signed-off-by: Matthias Hanel <mh@synadia.com>
Signed-off-by: Matthias Hanel <mh@synadia.com>
nats.go Outdated Show resolved Hide resolved
test/js_test.go Outdated Show resolved Hide resolved
@wallyqs
Copy link
Member

wallyqs commented May 25, 2021

As it is, this is replacing the nats.Direct option that used to do something similar to disable using the JetStream API, but instead of being an option it adds a new constructor called js, err := nc.BindJetStream(), that similar to the nats.BindStream() option assumes that there are JetStream streams/consumers are already bound to the current account due to an import for example, so it does not lookup or attempts to create them which can't be done in environments with limited permissions.

@ColinSullivan1
Copy link
Member

IIRC, with direct mode there was a potential problem of overlapping acks with duplicate consumers. Does that issue present itself here?

matthiashanel and others added 2 commits May 25, 2021 12:21
Co-authored-by: Waldemar Quevedo <wally@synadia.com>
Co-authored-by: Waldemar Quevedo <wally@synadia.com>
@matthiashanel
Copy link
Contributor Author

IIRC, with direct mode there was a potential problem of overlapping acks with duplicate consumers. Does that issue present itself here?

@ColinSullivan1 can you explain how this issue showed itself?

@wallyqs
Copy link
Member

wallyqs commented May 25, 2021

I think that @ColinSullivan1 means that if you run Subscribe multiple times and they are not a queue subscriber with the same durable name, they can all receive the same message that can be acked.

Signed-off-by: Matthias Hanel <mh@synadia.com>
test/js_test.go Outdated Show resolved Hide resolved
js.go Outdated Show resolved Hide resolved
matthiashanel and others added 2 commits May 25, 2021 13:58
Co-authored-by: Waldemar Quevedo <wally@synadia.com>
Co-authored-by: Waldemar Quevedo <wally@synadia.com>
Copy link
Member

@wallyqs wallyqs 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 whenever JetStream is imported from another account we could refer to it as being bound to the account as an import, LGTM.

@matthiashanel
Copy link
Contributor Author

@ColinSullivan1 @derekcollison is this change in it's current form ok with you?

@derekcollison
Copy link
Member

Let's setup a quick meeting for tomorrow to discuss. You and Colin and I and Wally..

@wallyqs
Copy link
Member

wallyqs commented Jun 8, 2021

Fixed via #740

@wallyqs wallyqs closed this Jun 8, 2021
@wallyqs wallyqs deleted the no-dur-create branch June 8, 2021 17:36
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

5 participants