Skip to content

Commit a863be4

Browse files
authored
Ftr: add feature for unix socket capability (apache#86)
* feat(dubbo): add unix feature * Rft: replace feature with target_os cfg
1 parent eef25df commit a863be4

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

dubbo/src/framework.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl Dubbo {
5353
}
5454

5555
pub fn init(&mut self) {
56-
let conf = self.config.get_or_insert_with(|| get_global_config());
56+
let conf = self.config.get_or_insert_with(get_global_config);
5757
tracing::debug!("global conf: {:?}", conf);
5858

5959
for (name, url) in conf.registries.iter() {

dubbo/src/triple/transport/connector/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717

1818
pub mod http_connector;
19+
#[cfg(target_os = "unix")]
1920
pub mod unix_connector;
2021

2122
use hyper::Uri;
@@ -78,6 +79,7 @@ pub fn get_connector(connector: String) -> BoxCloneService<Uri, BoxIO, crate::Er
7879
let c = http_connector::HttpConnector::new();
7980
BoxCloneService::new(Connector::new(c))
8081
}
82+
#[cfg(target_os = "unix")]
8183
"unix" => {
8284
let c = unix_connector::UnixConnector::new();
8385
BoxCloneService::new(Connector::new(c))

dubbo/src/triple/transport/listener/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717

1818
pub mod tcp_listener;
19+
#[cfg(target_os = "unix")]
1920
pub mod unix_listener;
2021

2122
use std::net::SocketAddr;
@@ -25,7 +26,6 @@ use tokio::io::{AsyncRead, AsyncWrite};
2526

2627
use super::io::BoxIO;
2728
pub use tcp_listener::TcpListener;
28-
pub use unix_listener::UnixListener;
2929

3030
#[async_trait]
3131
pub trait Listener: Send + Sync {
@@ -64,7 +64,8 @@ impl<T: Listener> Listener for WrappedListener<T> {
6464
pub async fn get_listener(name: String, addr: SocketAddr) -> Result<BoxListener, crate::Error> {
6565
match name.as_str() {
6666
"tcp" => Ok(TcpListener::bind(addr).await?.boxed()),
67-
"unix" => Ok(UnixListener::bind(addr).await?.boxed()),
67+
#[cfg(target_os = "unix")]
68+
"unix" => Ok(unix_listener::UnixListener::bind(addr).await?.boxed()),
6869
_ => {
6970
tracing::warn!("no support listener: {:?}", name);
7071
Err(Box::new(crate::status::DubboError::new(format!(

0 commit comments

Comments
 (0)