Skip to content

How to gracefully unsubscribe #910

Answered by YaZasnyal
initprism asked this question in Q&A
Discussion options

You must be logged in to vote

Unsubscribe is going to happen if the Subscription is dropped or by calling unsubscribe(). You need to signal a Task to unsubscribe and drain messages that are left. This can be done using tokio oneshot channel and select!ing both futures.

https://docs.rs/tokio/latest/tokio/sync/oneshot/fn.channel.html
https://docs.rs/tokio/latest/tokio/macro.select.html#examples

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by caspervonb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #907 on April 03, 2023 13:12.