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

js: make js.Subscribe context aware #872

Merged
merged 1 commit into from Dec 14, 2021
Merged

js: make js.Subscribe context aware #872

merged 1 commit into from Dec 14, 2021

Conversation

wallyqs
Copy link
Member

@wallyqs wallyqs commented Dec 14, 2021

Can now attach a context to a subscription so that it is unsubscribed and/or consumer deleted via propagation of cancellation via parent context. This helps specially with kv.Watch functions that have an ordered consumer subscription.

Signed-off-by: Waldemar Quevedo wally@synadia.com

@coveralls
Copy link

coveralls commented Dec 14, 2021

Coverage Status

Coverage increased (+0.3%) to 85.156% when pulling 16d26f8 on js-subscribe-ctx into d7c1d78 on main.

@ripienaar
Copy link
Contributor

Nice, I am not that concerned to make this work for kv atm though your change is small enough there.

For kv we must not accept WatchOpts on various places where its accepted now - we need to add a new kind of opt like CancelOpt that only accepts nats.Context() since that the only valid option for Keys() for example. I can take care of that once the basic cancelable subscribe and order consumer is in place

js.go Outdated Show resolved Hide resolved
Can now attach a context to a subscription so that it is
unsubscribed and/or consumer deleted via propagation of
cancellation via parent context.

Signed-off-by: Waldemar Quevedo <wally@synadia.com>
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

@wallyqs wallyqs merged commit b337a5c into main Dec 14, 2021
@wallyqs wallyqs deleted the js-subscribe-ctx branch December 14, 2021 22:02
@tpihl
Copy link

tpihl commented Dec 24, 2021

Will this work as a cancel more messages or will it delete a durable subscriber created in the subscribe call with WithDurable?

@wallyqs
Copy link
Member Author

wallyqs commented Dec 24, 2021

If the app auto-created the durable (that is, without using AddConsumer) then the durable subscriber will be deleted when the context is canceled as well.

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