-
Notifications
You must be signed in to change notification settings - Fork 27
refactor(noq)!: open path by four tuple and replace open_path_ensure with OpenPathOpts #655
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1039,6 +1039,41 @@ pub enum PathStatus { | |||||
| Backup, | ||||||
| } | ||||||
|
|
||||||
| /// Options for opening a new path via [`Connection::open_path`]. | ||||||
| /// | ||||||
| /// Defaults to [`PathStatus::Available`] and `allow_duplicate: false`. | ||||||
| /// | ||||||
| /// [`Connection::open_path`]: crate::Connection::open_path | ||||||
| #[derive(Debug, Copy, Clone, Default)] | ||||||
| pub struct OpenPathOpts { | ||||||
| pub(crate) initial_status: PathStatus, | ||||||
| pub(crate) allow_duplicate: bool, | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did you have a motivation to have to keep this option?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Do you think it should be removed?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In I recognise we use this functionality a lot in the tests, that's awkward and I need to think about this a bit more. My original thinking was to do the opposite: open_path would always open a path, and simply remove the I'm not really enthusiastic about this
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
noq/noq-proto/src/connection/mod.rs Line 5857 in 335b7b8
open_first is true we open before closing. The current logic is described here: noq/noq-proto/src/connection/mod.rs Line 5839 in 335b7b8
Why? Isn't it rarely the desired outcome to have multiple paths for the same FourTuple? Especially for public usage, I would guess you usually want to not create multiple paths for the same FourTuple. If Also, internally, when opening paths for successful NAT traversal probes, we only want to open paths when no path exists yet for the FourTuple. So I think it's either the Or do you have other ideas how to have a way to "only open if no path exists yet for this network path" with a single function?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think right now this is throwing too many questions that I can't resolve in the time we have for the RCs. I had reasons to want to remove the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. Opened #661 and closing this for now. If I come up with a better idea I'll do a new PR. |
||||||
| } | ||||||
|
|
||||||
| impl OpenPathOpts { | ||||||
| /// Sets the initial [`PathStatus`] for the new path. | ||||||
| #[must_use] | ||||||
| pub fn initial_status(mut self, initial_status: PathStatus) -> Self { | ||||||
| self.initial_status = initial_status; | ||||||
| self | ||||||
| } | ||||||
|
|
||||||
| /// Whether to open a new path even if another open path with the same network 4-tuple | ||||||
| /// already exists. | ||||||
| /// | ||||||
| /// When `false` (the default), [`Connection::open_path`] returns | ||||||
| /// [`PathError::PathExistsForNetworkPath`] if an open path with the same network 4-tuple | ||||||
| /// already exists. When `true`, a new path is opened regardless. | ||||||
| /// | ||||||
| /// [`Connection::open_path`]: crate::Connection::open_path | ||||||
| /// [`PathError::PathExistsForNetworkPath`]: crate::PathError::PathExistsForNetworkPath | ||||||
| #[must_use] | ||||||
| pub fn allow_duplicate(mut self, allow_duplicate: bool) -> Self { | ||||||
| self.allow_duplicate = allow_duplicate; | ||||||
| self | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| /// Application events about paths | ||||||
| #[derive(Debug, Clone, PartialEq, Eq)] | ||||||
| pub enum PathEvent { | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this new error needed? Why can the open_path function not simply return the PathId of the open path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I can remove it. The information whether
open_pathopened a new path or returned the PathId of an existing path would be lost. We currently only use it to log differently in one place, no functionality depends on this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, actually we can't with how I impl'd it, because in
noq::Connection::open_pathwe now rely on the contract thatnoq_proto::Connection::open_pathnow either returns a new path id or an error, but never an existing path id. This made the impl simpler (no more watch channels), but could be changed again.