Skip to content

Expose shutdown lifecycle on ChitchatHandle #162

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

Merged
merged 3 commits into from
Jul 10, 2025
Merged

Conversation

rdettai
Copy link
Collaborator

@rdettai rdettai commented Jun 25, 2025

To handle chitchat failures and panics in QW, we need to be able to watch its state (quickwit-oss/quickwit#5819)

@rdettai rdettai requested a review from guilload June 25, 2025 10:26
@@ -144,18 +146,23 @@ pub async fn spawn_chitchat(
let chitchat_arc = Arc::new(Mutex::new(chitchat));
let chitchat_arc_clone = chitchat_arc.clone();

let (termination_watcher_sender, termination_watcher) = watch::channel(None);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
let (termination_watcher_sender, termination_watcher) = watch::channel(None);
let (termination_watcher_sender, termination_watcher) = watch::channel(None);

I think that codebase adopts the _tx for sender and _rx for receiver naming scheme.
It is confusing, but common in rust.

@@ -186,6 +199,20 @@ impl ChitchatHandle {
self.command_tx.send(Command::Gossip(addr))?;
Ok(())
}

pub fn termination_watcher(&self) -> impl Future<Output = anyhow::Result<()>> {
let mut watcher = self.termination_watcher.clone();
Copy link
Collaborator

Choose a reason for hiding this comment

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

an alternative implementation could have been to add a deps to the futures crate and rely on future::shared() over the JoinHandle.

@fulmicoton-dd fulmicoton-dd merged commit e632b15 into main Jul 10, 2025
4 of 5 checks passed
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.

2 participants