feat: add close_link method to TransportUnicast API - #2745
Open
gabrik wants to merge 5 commits into
Open
Conversation
Add close_link(Link) to the TransportUnicastTrait and expose it through the TransportUnicast public wrapper. This allows closing a specific link within a multilink transport without tearing down the entire transport. - TransportUnicastUniversal: delegates to existing del_link() - TransportUnicastLowlatency: closes the entire transport (it has at most one link) - MockTransportUnicastInner: no-op stub for tests
Add two tests for close_link: - transport_unicast_close_link_multilink: verify that closing one of two links keeps the transport alive, then closing the last link closes the transport - transport_unicast_close_link_single_link: verify that closing the only link closes the entire transport Also add a doc example to the close_link method on TransportUnicast.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2745 +/- ##
==========================================
+ Coverage 74.67% 74.69% +0.01%
==========================================
Files 425 419 -6
Lines 63930 63837 -93
==========================================
- Hits 47739 47680 -59
+ Misses 16191 16157 -34 ☔ View full report in Codecov by Harness. |
Add transport_unicast_close_link_lowlatency test that exercises the close_link path on the lowlatency transport (which has at most one link, so closing it closes the entire transport). This covers the previously uncovered close_link implementation in lowlatency/transport.rs.
The doc test for close_link failed because: 1. .await was used outside an async block 2. TransportUnicast is not exported at crate root Fix by wrapping the example body in and using the full path zenoh_transport::unicast::TransportUnicast.
gabrik
requested review from
fuzzypixelz and
oteffahi
and removed request for
oteffahi
August 20, 2026 14:21
fuzzypixelz
approved these changes
Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
close_link(Link)to theTransportUnicastTraitand expose it through theTransportUnicastpublic wrapper. This allows closing a specific link within a multilink transport without tearing down the entire transport.Changes
TransportUnicastTrait: newasync fn close_link(&self, link: Link) -> ZResult<()>on the traitTransportUnicastUniversal: delegates to existingdel_link()TransportUnicastLowlatency: closes the entire transport (it has at most one link)MockTransportUnicastInner: no-op stub for testsTransportUnicast: publicclose_link()wrapper exposed with doc exampleMotivation
This is a prerequisite for transport link rotation (see #2746), where the rotation engine needs to close individual links within a multilink transport during make-before-break cycles. The existing
del_linkmethod onTransportUnicastUniversalwaspub(crate)and not exposed through the trait or the public wrapper.Tests
transport_unicast_close_link_multilink: closes one of two links, verifies transport survives, then closes the last link and verifies transport closestransport_unicast_close_link_single_link: closes the only link, verifies transport closes🏷️ Label-Based Checklist
Based on the labels applied to this PR, please complete these additional requirements:
Labels:
new feature🆕 New Feature Requirements
Since this PR adds a new feature:
Consider: Can this feature be split into smaller, incremental PRs?
Instructions:
- [ ]to- [x])This checklist updates automatically when labels change, but preserves your checked boxes.