-
Notifications
You must be signed in to change notification settings - Fork 178
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
Unix Domain Socket transport #55
Unix Domain Socket transport #55
Conversation
…domain socket path> Signed-off-by: gabrik <[email protected]>
Signed-off-by: gabrik <[email protected]>
…domain socket path> Signed-off-by: gabrik <[email protected]>
Signed-off-by: gabrik <[email protected]>
Signed-off-by: gabrik <[email protected]>
Signed-off-by: gabrik <[email protected]>
Signed-off-by: gabrik <[email protected]>
Signed-off-by: gabrik <[email protected]>
… fixed use in link/mod.rs Signed-off-by: gabrik <[email protected]>
I'm not sure "unix" is a good idea for the Cargo feature name as:
|
zenoh-protocol/tests/channel.rs
Outdated
let _ = std::fs::remove_file("/tmp/socket.sock"); | ||
// Define the locator | ||
let locators: Vec<Locator> = vec!["unix//tmp/socket.sock".parse().unwrap()]; | ||
// Define the reliability and congestgino control |
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.
Typo in congestion control.
zenoh-protocol/tests/channel.rs
Outdated
fn channel_unix() { | ||
let _ = std::fs::remove_file("/tmp/socket.sock"); | ||
// Define the locator | ||
let locators: Vec<Locator> = vec!["unix//tmp/socket.sock".parse().unwrap()]; |
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.
Change the file name to something more self-explanatory, e.g., zenoh-test-unix-socket.sock
zenoh-protocol/src/link/locator.rs
Outdated
@@ -63,19 +71,35 @@ pub enum Locator { | |||
Tcp(SocketAddr), | |||
#[cfg(feature = "udp")] | |||
Udp(SocketAddr), | |||
#[cfg(all(feature = "unix", target_family = "unix"))] | |||
Unix(PathBuf), |
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.
I suggest to call the locator UnixDomainSocket and not simply Unix, alternatively we can use Uds.
zenoh-protocol/src/link/manager.rs
Outdated
@@ -17,6 +17,8 @@ use async_std::sync::Arc; | |||
use crate::link::tcp::ManagerTcp; | |||
#[cfg(feature = "udp")] | |||
use crate::link::udp::ManagerUdp; | |||
#[cfg(all(feature = "unix", target_family = "unix"))] | |||
use crate::link::unix::ManagerUnix; |
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.
I suggest to call the ManagerUnixSocket instead of ManagerUnix
zenoh-protocol/tests/channel.rs
Outdated
// Define the locator | ||
let locators: Vec<Locator> = vec![ | ||
"tcp/127.0.0.1:7449".parse().unwrap(), | ||
"unix//tmp/socket_1.sock".parse().unwrap(), |
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.
Change the file name to something more self-explanatory, e.g., zenoh-test-unix-socket_1.sock
zenoh-protocol/tests/channel.rs
Outdated
#[cfg(all(feature = "unix", target_family = "unix"))] | ||
#[test] | ||
fn channel_tcp_unix() { | ||
let _ = std::fs::remove_file("/tmp/socket_1.sock"); |
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.
Although /tmp is available in the totality of the system, I believe that using the current directory for the unix socket path is a better approach:
It is guaranteed that the cargo test will have write permissions while executing the test
System files are not created outside the test directory
I also suggest to use a more explanatory name for the socket, e.g., zenoh-test-unix-socket_1.sock
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.
Another solution is use the tempfile crate that relies on std::env::temp_dir and performs automatic deletion of file.
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.
I like the idea of using the tempfile crate. This should be added to the dev dependencies.
zenoh-protocol/tests/channel.rs
Outdated
#[cfg(all(feature = "unix", target_family = "unix"))] | ||
#[test] | ||
fn channel_unix() { | ||
let _ = std::fs::remove_file("/tmp/socket.sock"); |
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.
Although /tmp is available in the totality of the system, I believe that using the current directory for the unix socket path is a better approach:
It is guaranteed that the cargo test will have write permissions while executing the test
System files are not created outside the test directory
I also suggest to use a more explanatory name for the socket, e.g., zenoh-test-unix-socket.sock
zenoh-protocol/tests/channel.rs
Outdated
#[cfg(all(feature = "unix", target_family = "unix"))] | ||
#[test] | ||
fn channel_udp_unix() { | ||
let _ = std::fs::remove_file("/tmp/socket_2.sock"); |
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.
Change the file name to something more self-explanatory, e.g., zenoh-test-unix-socket_2.sock
zenoh-protocol/tests/channel.rs
Outdated
// Define the locator | ||
let locators: Vec<Locator> = vec![ | ||
"udp/127.0.0.1:7449".parse().unwrap(), | ||
"unix//tmp/socket_2.sock".parse().unwrap(), |
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.
Change the file name to something more self-explanatory, e.g., zenoh-test-unix-socket_2.sock
zenoh-protocol/src/link/locator.rs
Outdated
@@ -36,13 +38,17 @@ pub const PORT_SEPARATOR: char = ':'; | |||
pub const STR_TCP: &str = "tcp"; | |||
#[cfg(feature = "udp")] | |||
pub const STR_UDP: &str = "udp"; | |||
#[cfg(all(feature = "unix", target_family = "unix"))] | |||
pub const STR_UNIX: &str = "unix"; |
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.
My proposal for the locator protocol is to use "uds" from "unix domain socket". Other proposals are also accepted.
zenoh-protocol/src/link/unix.rs
Outdated
/*************************************/ | ||
/* LINK */ | ||
/*************************************/ | ||
pub struct Unix { |
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.
We should avoid ambiguity on the usage of term Unix here. I suggest either to use:
- UnixDomainSocket
- Uds
I would be tempted to go even further and have a clearer approach in the whole zenoh. Any feature related to a transport technology should be trasport_*. I.e., existing tcp and udp features should be also renamed to transport_tcp and transport_udp. What do you think? |
Signed-off-by: gabrik <[email protected]>
Signed-off-by: gabrik <[email protected]>
This PR contains the code to implement the Unix Domain Sockets as transport for Zenoh
Creating a draft to keep track of the work
unix/<domain socket path>
unix
feature for this transport