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

[pubsub] Support grafeful shutdown for MessageStream #267

Merged
merged 10 commits into from
May 17, 2024

Conversation

yoshidan
Copy link
Owner

#266

let token = tokio_util::sync::CancellationToke::new();
let child_token = token.child_token();

let task = tokio::spawn(async move {
   let mut stream = subscription.subscribe(None).await.unwrap();
            
    while let Some(message) = tokio::select! {
        msg = stream.next() => msg,
        _ = child_token.cancelled() => None
    } {
         ...
    }
    stream.dispose().await
});

token.cancel();
task.await();

@yoshidan yoshidan force-pushed the feature/gracefull_message_stream branch from 1472f11 to 2f3a34c Compare May 16, 2024 01:08
@yoshidan yoshidan marked this pull request as ready for review May 16, 2024 08:37
@yoshidan yoshidan added the safe to test safe to test label May 16, 2024
@yoshidan yoshidan added safe to test safe to test and removed safe to test safe to test labels May 16, 2024
@yoshidan yoshidan merged commit b8211a6 into main May 17, 2024
12 of 14 checks passed
@yoshidan yoshidan deleted the feature/gracefull_message_stream branch August 1, 2024 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test safe to test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant