This is an automated email from the ASF dual-hosted git repository.

yangyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git


The following commit(s) were added to refs/heads/main by this push:
     new a863be4  Ftr: add feature for unix socket capability (#86)
a863be4 is described below

commit a863be454b2da4f8049bb3cb201273a36ff8388c
Author: Yang Yang <[email protected]>
AuthorDate: Fri Dec 9 20:40:01 2022 +0800

    Ftr: add feature for unix socket capability (#86)
    
    * feat(dubbo): add unix feature
    
    * Rft: replace feature with target_os cfg
---
 dubbo/src/framework.rs                      | 2 +-
 dubbo/src/triple/transport/connector/mod.rs | 2 ++
 dubbo/src/triple/transport/listener/mod.rs  | 5 +++--
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/dubbo/src/framework.rs b/dubbo/src/framework.rs
index da21ab8..412ff36 100644
--- a/dubbo/src/framework.rs
+++ b/dubbo/src/framework.rs
@@ -53,7 +53,7 @@ impl Dubbo {
     }
 
     pub fn init(&mut self) {
-        let conf = self.config.get_or_insert_with(|| get_global_config());
+        let conf = self.config.get_or_insert_with(get_global_config);
         tracing::debug!("global conf: {:?}", conf);
 
         for (name, url) in conf.registries.iter() {
diff --git a/dubbo/src/triple/transport/connector/mod.rs 
b/dubbo/src/triple/transport/connector/mod.rs
index 89ae555..82b9281 100644
--- a/dubbo/src/triple/transport/connector/mod.rs
+++ b/dubbo/src/triple/transport/connector/mod.rs
@@ -16,6 +16,7 @@
  */
 
 pub mod http_connector;
+#[cfg(target_os = "unix")]
 pub mod unix_connector;
 
 use hyper::Uri;
@@ -78,6 +79,7 @@ pub fn get_connector(connector: String) -> 
BoxCloneService<Uri, BoxIO, crate::Er
             let c = http_connector::HttpConnector::new();
             BoxCloneService::new(Connector::new(c))
         }
+        #[cfg(target_os = "unix")]
         "unix" => {
             let c = unix_connector::UnixConnector::new();
             BoxCloneService::new(Connector::new(c))
diff --git a/dubbo/src/triple/transport/listener/mod.rs 
b/dubbo/src/triple/transport/listener/mod.rs
index d755cd3..6beb215 100644
--- a/dubbo/src/triple/transport/listener/mod.rs
+++ b/dubbo/src/triple/transport/listener/mod.rs
@@ -16,6 +16,7 @@
  */
 
 pub mod tcp_listener;
+#[cfg(target_os = "unix")]
 pub mod unix_listener;
 
 use std::net::SocketAddr;
@@ -25,7 +26,6 @@ use tokio::io::{AsyncRead, AsyncWrite};
 
 use super::io::BoxIO;
 pub use tcp_listener::TcpListener;
-pub use unix_listener::UnixListener;
 
 #[async_trait]
 pub trait Listener: Send + Sync {
@@ -64,7 +64,8 @@ impl<T: Listener> Listener for WrappedListener<T> {
 pub async fn get_listener(name: String, addr: SocketAddr) -> 
Result<BoxListener, crate::Error> {
     match name.as_str() {
         "tcp" => Ok(TcpListener::bind(addr).await?.boxed()),
-        "unix" => Ok(UnixListener::bind(addr).await?.boxed()),
+        #[cfg(target_os = "unix")]
+        "unix" => Ok(unix_listener::UnixListener::bind(addr).await?.boxed()),
         _ => {
             tracing::warn!("no support listener: {:?}", name);
             Err(Box::new(crate::status::DubboError::new(format!(

Reply via email to