Skip to content

capnp-rpc: Add disconnect_background to Disconnector #581

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

griff
Copy link
Contributor

@griff griff commented Aug 11, 2025

This adds a public disconnect_background function to Disconnector so that you can signal it to disconnect but not have to wait for it to do so.

I usually run the RpcSystem with spawn_local and would like to be able to just signal that it should shut down in like a Drop implementation for my Client.

It would also make my graceful shutdown listener for the server slightly less clunky since that needs to do this:

if this.cancelled_guard.is_some() {
    match (
        this.rpc_system.as_mut().poll(cx)?,
        this.disconnector.as_mut().poll(cx)?,
    ) {
        (task::Poll::Ready(_), task::Poll::Ready(_)) => task::Poll::Ready(Ok(())),
        _ => task::Poll::Pending,
    }
} else {
    this.rpc_system.poll(cx)
}

While with this PR it would look like this:

if this.cancelled_guard.is_some() {
    this.disconnector.disconnect_background();
}
this.rpc_system.poll(cx)

This adds a public disconnect_background function to Disconnector so that
you can signal it to disconnect but not have to wait for it to do so.
Copy link

codecov bot commented Aug 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.65%. Comparing base (ab342b3) to head (6776bd7).
⚠️ Report is 188 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #581      +/-   ##
==========================================
- Coverage   51.64%   50.65%   -1.00%     
==========================================
  Files          69       70       +1     
  Lines       33735    32295    -1440     
==========================================
- Hits        17422    16358    -1064     
+ Misses      16313    15937     -376     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant