refactor(iroh)!: redesign path observation API#4188
Open
Frando wants to merge 1 commit intoFrando/noq-path-stats-on-closefrom
Open
refactor(iroh)!: redesign path observation API#4188Frando wants to merge 1 commit intoFrando/noq-path-stats-on-closefrom
Frando wants to merge 1 commit intoFrando/noq-path-stats-on-closefrom
Conversation
aee38bd to
f418de8
Compare
|
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/4188/docs/iroh/ Last updated: 2026-05-05T13:40:21Z |
f418de8 to
15f83e3
Compare
8d3ec38 to
ea4c208
Compare
15f83e3 to
a5d7b28
Compare
8c8a892 to
e99bc03
Compare
ea4c208 to
3c9c395
Compare
e99bc03 to
4be4d88
Compare
148e40d to
72a8078
Compare
4 tasks
1d5d67c to
488a321
Compare
488a321 to
a5b561b
Compare
d0dc079 to
d2b7403
Compare
524f70d to
8e10c37
Compare
f07effc to
19b034e
Compare
19b034e to
dd59f9f
Compare
| }, | ||
| /// The subscriber fell behind and missed events. | ||
| /// | ||
| /// The current state is recoverable via [`Connection::paths`]. |
Contributor
There was a problem hiding this comment.
what exactly does this mean?
Frando
added a commit
that referenced
this pull request
May 5, 2026
…ed (#4229) ## Description Updates `noq` and adapts iroh to the changes in n0-computer/noq#617 by reexporting `noq::Closed`. ## Breaking Changes * changed: The `OnClosed` future returned from `iroh::endpoint::WeakConnectionHandle::closed` now resolves to `iroh::endpoint::Closed`, a struct with public fields for the close reason, connection stats, and path stats. ## Notes & open questions It would be nice to have the `TransportAddr` available for the path stats, but we don't have that info available for paths that were already closed earlier. Use the new APIs in #4188 instead if this needed. ## Change checklist <!-- Remove any that are not relevant. --> - [x] Self-review. - [x] Documentation updates following the [style guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text), if relevant. - [x] Tests if relevant. - [x] All breaking changes documented.
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.
Depends on n0-computer/noq#617
Based on #4229
This replaces the current
PathWatcherwith a new combination of primitives.Connection::pathsreturnsPathList<'conn>, a list of the currently-open paths. Iteration yieldsPath<'conn>with access to the remote address, selection state, and path stats. ThePathListis a snapshot in time (ie., once returned fromConnection::pathswon't change for changes in the path list). It is also lifetime-bound to theConnection(which gives us unconditional access to path stats right out of the noq state).Connection::path_events()returns aPathEventStreamof path events. This stream is lifetime-free, can be sent to other tasks, and does not keep theConnectionalive. The subscription is registered immediately at call time so pairing it with a subsequentpaths()read produces a race-free check-then-wait loop.Connection::path_updatesreturns a stream that yieldsPathList<'conn>whenever the path list changes (ie. on path open/close or selection change)PathEventhas four variants:Opened,Closed(withlast_statsinline),Selected, and aLagged(with the missed count) to account for the (rare) case of a broadcast stream lag.Closed paths are no longer retained in
Paths. Consumers that need totals over the connection's lifetime accumulate fromPathEvent:: Closed; thetransfer.rsexample'sspawn_stats_collectordemonstrates this pattern.Internally, the path store splits into two handles sharing an
Mutex<State>, containing aSmallVecof(PathId, TransportAddr)plus the selected path id.PathStateSender, owned by theRemoteStateActor, is the sole mutator and holds the broadcastSender.PathStateReceiver, held by theConnection, reads viaArcSwapand subscribes via aWeakSender. When theConnectionStateis dropped, the broadcastSenderis dropped with it and outstanding event streams end naturally; new subscriptions on a closed connection where the remote state actor already dropped its state then yield an already-closed stream.Final per-path statistics now come from
noq::Closed::path_statsat connection close time, via n0-computer/noq#617.Breaking Changes
iroh::endpoint::PathWatcher,iroh::endpoint::PathInfo,iroh::endpoint::PathInfoList,iroh::endpoint::PathInfoListIter.Connection::pathsreturnsPathList<'_>instead ofPathWatcher.Path<'_>replacesPathInfo;Path::statsis now infallibleConnectionInfo::pathsis removed in favour ofConnectionInfo::path_events.ConnectionInfo::selected_pathnow returnsOption<TransportAddr>instead ofOption<PathInfo>.iroh::endpoint::Path,iroh::endpoint::Paths,iroh::endpoint::PathEvent(withOpened,Closed,Selected,Laggedvariants),iroh::endpoint::PathEventStream,Connection::path_events,ConnectionInfo::path_events.Change checklist