Revert "Rft: using subpackage to manage registry implementations for avoiding root-level directory abuse. (#121)"
This reverts commit 4771b69320bdfb052773036c60302a5a2a49523f.
diff --git a/Cargo.toml b/Cargo.toml
index ae339cd..d18fab3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,8 +1,9 @@
[workspace]
members = [
"xds",
- "registry/zookeeper",
- "registry/nacos",
+ "registry",
+ "registry-zookeeper",
+ "registry-nacos",
"metadata",
"config",
"dubbo",
@@ -26,10 +27,4 @@
futures = "0.3"
tracing = "0.1"
tracing-subscriber = "0.3.15"
-serde = "1"
-serde_json = "1"
-urlencoding = "2.1.2"
-logger = {path="./common/logger"}
-anyhow = "1.0.66"
-dubbo = { path = "./dubbo/" }
diff --git a/examples/echo/Cargo.toml b/examples/echo/Cargo.toml
index 93ba6d9..82d1554 100644
--- a/examples/echo/Cargo.toml
+++ b/examples/echo/Cargo.toml
@@ -34,7 +34,7 @@
dubbo = {path = "../../dubbo", version = "0.3.0" }
dubbo-config = {path = "../../config", version = "0.3.0" }
-dubbo-registry-zookeeper = {path = "../../registry/zookeeper", version = "0.3.0" }
+dubbo-registry-zookeeper = {path = "../../registry-zookeeper", version = "0.3.0" }
[build-dependencies]
dubbo-build = {path = "../../dubbo-build", version = "0.3.0" }
diff --git a/examples/echo/src/generated/grpc.examples.echo.rs b/examples/echo/src/generated/grpc.examples.echo.rs
index ccb385c..c095ddf 100644
--- a/examples/echo/src/generated/grpc.examples.echo.rs
+++ b/examples/echo/src/generated/grpc.examples.echo.rs
@@ -1,15 +1,15 @@
+// @generated by apache/dubbo-rust.
+
/// EchoRequest is the request for echo.
-#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EchoRequest {
- #[prost(string, tag = "1")]
+ #[prost(string, tag="1")]
pub message: ::prost::alloc::string::String,
}
/// EchoResponse is the response for echo.
-#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EchoResponse {
- #[prost(string, tag = "1")]
+ #[prost(string, tag="1")]
pub message: ::prost::alloc::string::String,
}
/// Generated client implementations.
@@ -40,12 +40,16 @@
&mut self,
request: Request<super::EchoRequest>,
) -> Result<Response<super::EchoResponse>, dubbo::status::Status> {
- let codec =
- dubbo::codegen::ProstCodec::<super::EchoRequest, super::EchoResponse>::default();
+ let codec = dubbo::codegen::ProstCodec::<
+ super::EchoRequest,
+ super::EchoResponse,
+ >::default();
let invocation = RpcInvocation::default()
.with_service_unique_name(String::from("grpc.examples.echo.Echo"))
.with_method_name(String::from("UnaryEcho"));
- let path = http::uri::PathAndQuery::from_static("/grpc.examples.echo.Echo/UnaryEcho");
+ let path = http::uri::PathAndQuery::from_static(
+ "/grpc.examples.echo.Echo/UnaryEcho",
+ );
self.inner.unary(request, codec, path, invocation).await
}
/// ServerStreamingEcho is server side streaming.
@@ -53,51 +57,51 @@
&mut self,
request: Request<super::EchoRequest>,
) -> Result<Response<Decoding<super::EchoResponse>>, dubbo::status::Status> {
- let codec =
- dubbo::codegen::ProstCodec::<super::EchoRequest, super::EchoResponse>::default();
+ let codec = dubbo::codegen::ProstCodec::<
+ super::EchoRequest,
+ super::EchoResponse,
+ >::default();
let invocation = RpcInvocation::default()
.with_service_unique_name(String::from("grpc.examples.echo.Echo"))
.with_method_name(String::from("ServerStreamingEcho"));
let path = http::uri::PathAndQuery::from_static(
"/grpc.examples.echo.Echo/ServerStreamingEcho",
);
- self.inner
- .server_streaming(request, codec, path, invocation)
- .await
+ self.inner.server_streaming(request, codec, path, invocation).await
}
/// ClientStreamingEcho is client side streaming.
pub async fn client_streaming_echo(
&mut self,
request: impl IntoStreamingRequest<Message = super::EchoRequest>,
) -> Result<Response<super::EchoResponse>, dubbo::status::Status> {
- let codec =
- dubbo::codegen::ProstCodec::<super::EchoRequest, super::EchoResponse>::default();
+ let codec = dubbo::codegen::ProstCodec::<
+ super::EchoRequest,
+ super::EchoResponse,
+ >::default();
let invocation = RpcInvocation::default()
.with_service_unique_name(String::from("grpc.examples.echo.Echo"))
.with_method_name(String::from("ClientStreamingEcho"));
let path = http::uri::PathAndQuery::from_static(
"/grpc.examples.echo.Echo/ClientStreamingEcho",
);
- self.inner
- .client_streaming(request, codec, path, invocation)
- .await
+ self.inner.client_streaming(request, codec, path, invocation).await
}
/// BidirectionalStreamingEcho is bidi streaming.
pub async fn bidirectional_streaming_echo(
&mut self,
request: impl IntoStreamingRequest<Message = super::EchoRequest>,
) -> Result<Response<Decoding<super::EchoResponse>>, dubbo::status::Status> {
- let codec =
- dubbo::codegen::ProstCodec::<super::EchoRequest, super::EchoResponse>::default();
+ let codec = dubbo::codegen::ProstCodec::<
+ super::EchoRequest,
+ super::EchoResponse,
+ >::default();
let invocation = RpcInvocation::default()
.with_service_unique_name(String::from("grpc.examples.echo.Echo"))
.with_method_name(String::from("BidirectionalStreamingEcho"));
let path = http::uri::PathAndQuery::from_static(
"/grpc.examples.echo.Echo/BidirectionalStreamingEcho",
);
- self.inner
- .bidi_streaming(request, codec, path, invocation)
- .await
+ self.inner.bidi_streaming(request, codec, path, invocation).await
}
}
}
@@ -114,7 +118,9 @@
request: Request<super::EchoRequest>,
) -> Result<Response<super::EchoResponse>, dubbo::status::Status>;
///Server streaming response type for the ServerStreamingEcho method.
- type ServerStreamingEchoStream: futures_util::Stream<Item = Result<super::EchoResponse, dubbo::status::Status>>
+ type ServerStreamingEchoStream: futures_util::Stream<
+ Item = Result<super::EchoResponse, dubbo::status::Status>,
+ >
+ Send
+ 'static;
/// ServerStreamingEcho is server side streaming.
@@ -128,14 +134,19 @@
request: Request<Decoding<super::EchoRequest>>,
) -> Result<Response<super::EchoResponse>, dubbo::status::Status>;
///Server streaming response type for the BidirectionalStreamingEcho method.
- type BidirectionalStreamingEchoStream: futures_util::Stream<Item = Result<super::EchoResponse, dubbo::status::Status>>
+ type BidirectionalStreamingEchoStream: futures_util::Stream<
+ Item = Result<super::EchoResponse, dubbo::status::Status>,
+ >
+ Send
+ 'static;
/// BidirectionalStreamingEcho is bidi streaming.
async fn bidirectional_streaming_echo(
&self,
request: Request<Decoding<super::EchoRequest>>,
- ) -> Result<Response<Self::BidirectionalStreamingEchoStream>, dubbo::status::Status>;
+ ) -> Result<
+ Response<Self::BidirectionalStreamingEchoStream>,
+ dubbo::status::Status,
+ >;
}
/// Echo is the echo service.
#[derive(Debug)]
@@ -165,7 +176,10 @@
type Response = http::Response<BoxBody>;
type Error = std::convert::Infallible;
type Future = BoxFuture<Self::Response, Self::Error>;
- fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
+ fn poll_ready(
+ &mut self,
+ _cx: &mut Context<'_>,
+ ) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
@@ -178,18 +192,26 @@
}
impl<T: Echo> UnarySvc<super::EchoRequest> for UnaryEchoServer<T> {
type Response = super::EchoResponse;
- type Future = BoxFuture<Response<Self::Response>, dubbo::status::Status>;
- fn call(&mut self, request: Request<super::EchoRequest>) -> Self::Future {
+ type Future = BoxFuture<
+ Response<Self::Response>,
+ dubbo::status::Status,
+ >;
+ fn call(
+ &mut self,
+ request: Request<super::EchoRequest>,
+ ) -> Self::Future {
let inner = self.inner.0.clone();
let fut = async move { inner.unary_echo(request).await };
Box::pin(fut)
}
}
let fut = async move {
- let mut server = TripleServer::new(dubbo::codegen::ProstCodec::<
- super::EchoResponse,
- super::EchoRequest,
- >::default());
+ let mut server = TripleServer::new(
+ dubbo::codegen::ProstCodec::<
+ super::EchoResponse,
+ super::EchoRequest,
+ >::default(),
+ );
let res = server.unary(UnaryEchoServer { inner }, req).await;
Ok(res)
};
@@ -200,22 +222,32 @@
struct ServerStreamingEchoServer<T: Echo> {
inner: _Inner<T>,
}
- impl<T: Echo> ServerStreamingSvc<super::EchoRequest> for ServerStreamingEchoServer<T> {
+ impl<T: Echo> ServerStreamingSvc<super::EchoRequest>
+ for ServerStreamingEchoServer<T> {
type Response = super::EchoResponse;
type ResponseStream = T::ServerStreamingEchoStream;
- type Future =
- BoxFuture<Response<Self::ResponseStream>, dubbo::status::Status>;
- fn call(&mut self, request: Request<super::EchoRequest>) -> Self::Future {
+ type Future = BoxFuture<
+ Response<Self::ResponseStream>,
+ dubbo::status::Status,
+ >;
+ fn call(
+ &mut self,
+ request: Request<super::EchoRequest>,
+ ) -> Self::Future {
let inner = self.inner.0.clone();
- let fut = async move { inner.server_streaming_echo(request).await };
+ let fut = async move {
+ inner.server_streaming_echo(request).await
+ };
Box::pin(fut)
}
}
let fut = async move {
- let mut server = TripleServer::new(dubbo::codegen::ProstCodec::<
- super::EchoResponse,
- super::EchoRequest,
- >::default());
+ let mut server = TripleServer::new(
+ dubbo::codegen::ProstCodec::<
+ super::EchoResponse,
+ super::EchoRequest,
+ >::default(),
+ );
let res = server
.server_streaming(ServerStreamingEchoServer { inner }, req)
.await;
@@ -228,23 +260,31 @@
struct ClientStreamingEchoServer<T: Echo> {
inner: _Inner<T>,
}
- impl<T: Echo> ClientStreamingSvc<super::EchoRequest> for ClientStreamingEchoServer<T> {
+ impl<T: Echo> ClientStreamingSvc<super::EchoRequest>
+ for ClientStreamingEchoServer<T> {
type Response = super::EchoResponse;
- type Future = BoxFuture<Response<Self::Response>, dubbo::status::Status>;
+ type Future = BoxFuture<
+ Response<Self::Response>,
+ dubbo::status::Status,
+ >;
fn call(
&mut self,
request: Request<Decoding<super::EchoRequest>>,
) -> Self::Future {
let inner = self.inner.0.clone();
- let fut = async move { inner.client_streaming_echo(request).await };
+ let fut = async move {
+ inner.client_streaming_echo(request).await
+ };
Box::pin(fut)
}
}
let fut = async move {
- let mut server = TripleServer::new(dubbo::codegen::ProstCodec::<
- super::EchoResponse,
- super::EchoRequest,
- >::default());
+ let mut server = TripleServer::new(
+ dubbo::codegen::ProstCodec::<
+ super::EchoResponse,
+ super::EchoRequest,
+ >::default(),
+ );
let res = server
.client_streaming(ClientStreamingEchoServer { inner }, req)
.await;
@@ -257,41 +297,56 @@
struct BidirectionalStreamingEchoServer<T: Echo> {
inner: _Inner<T>,
}
- impl<T: Echo> StreamingSvc<super::EchoRequest> for BidirectionalStreamingEchoServer<T> {
+ impl<T: Echo> StreamingSvc<super::EchoRequest>
+ for BidirectionalStreamingEchoServer<T> {
type Response = super::EchoResponse;
type ResponseStream = T::BidirectionalStreamingEchoStream;
- type Future =
- BoxFuture<Response<Self::ResponseStream>, dubbo::status::Status>;
+ type Future = BoxFuture<
+ Response<Self::ResponseStream>,
+ dubbo::status::Status,
+ >;
fn call(
&mut self,
request: Request<Decoding<super::EchoRequest>>,
) -> Self::Future {
let inner = self.inner.0.clone();
- let fut =
- async move { inner.bidirectional_streaming_echo(request).await };
+ let fut = async move {
+ inner.bidirectional_streaming_echo(request).await
+ };
Box::pin(fut)
}
}
let fut = async move {
- let mut server = TripleServer::new(dubbo::codegen::ProstCodec::<
- super::EchoResponse,
- super::EchoRequest,
- >::default());
+ let mut server = TripleServer::new(
+ dubbo::codegen::ProstCodec::<
+ super::EchoResponse,
+ super::EchoRequest,
+ >::default(),
+ );
let res = server
- .bidi_streaming(BidirectionalStreamingEchoServer { inner }, req)
+ .bidi_streaming(
+ BidirectionalStreamingEchoServer {
+ inner,
+ },
+ req,
+ )
.await;
Ok(res)
};
Box::pin(fut)
}
- _ => Box::pin(async move {
- Ok(http::Response::builder()
- .status(200)
- .header("grpc-status", "12")
- .header("content-type", "application/grpc")
- .body(empty_body())
- .unwrap())
- }),
+ _ => {
+ Box::pin(async move {
+ Ok(
+ http::Response::builder()
+ .status(200)
+ .header("grpc-status", "12")
+ .header("content-type", "application/grpc")
+ .body(empty_body())
+ .unwrap(),
+ )
+ })
+ }
}
}
}
diff --git a/examples/greeter/Cargo.toml b/examples/greeter/Cargo.toml
index 0b14d1a..491f405 100644
--- a/examples/greeter/Cargo.toml
+++ b/examples/greeter/Cargo.toml
@@ -31,7 +31,7 @@
logger = {path="../../common/logger"}
dubbo = {path = "../../dubbo", version = "0.3.0" }
dubbo-config = {path = "../../config", version = "0.3.0" }
-dubbo-registry-zookeeper = {path = "../../registry/zookeeper", version = "0.3.0" }
+dubbo-registry-zookeeper = {path = "../../registry-zookeeper", version = "0.3.0" }
[build-dependencies]
dubbo-build = {path = "../../dubbo-build", version = "0.3.0" }
diff --git a/registry/nacos/Cargo.toml b/registry-nacos/Cargo.toml
similarity index 73%
rename from registry/nacos/Cargo.toml
rename to registry-nacos/Cargo.toml
index 36a8fd1..2a86a45 100644
--- a/registry/nacos/Cargo.toml
+++ b/registry-nacos/Cargo.toml
@@ -10,10 +10,11 @@
[dependencies]
nacos-sdk = { version = "0.2", features = ["naming", "auth-by-http"] }
-dubbo.workspace = true
-serde_json.workspace = true
-serde = { workspace = true, features = ["derive"] }
-anyhow.workspace = true
-logger.workspace = true
+dubbo = {path = "../dubbo/", version = "0.3.0" }
+serde_json = "1.0"
+serde = {version = "1.0.145",features = ["derive"]}
+tracing = "0.1"
+anyhow = "1.0.66"
+
[dev-dependencies]
tracing-subscriber = "0.3.16"
diff --git a/registry/nacos/LICENSE b/registry-nacos/LICENSE
similarity index 100%
rename from registry/nacos/LICENSE
rename to registry-nacos/LICENSE
diff --git a/registry/nacos/src/lib.rs b/registry-nacos/src/lib.rs
similarity index 100%
rename from registry/nacos/src/lib.rs
rename to registry-nacos/src/lib.rs
diff --git a/registry/nacos/src/nacos_registry.rs b/registry-nacos/src/nacos_registry.rs
similarity index 99%
rename from registry/nacos/src/nacos_registry.rs
rename to registry-nacos/src/nacos_registry.rs
index 0ec8b40..2d0d669 100644
--- a/registry/nacos/src/nacos_registry.rs
+++ b/registry-nacos/src/nacos_registry.rs
@@ -25,8 +25,8 @@
common::url::Url,
registry::{NotifyListener, Registry, RegistryNotifyListener, ServiceEvent},
};
-use logger::tracing::{error, info, warn};
use nacos_sdk::api::naming::{NamingService, NamingServiceBuilder, ServiceInstance};
+use tracing::{error, info, warn};
use crate::utils::{build_nacos_client_props, is_concrete_str, is_wildcard_str, match_range};
diff --git a/registry/nacos/src/utils/mod.rs b/registry-nacos/src/utils/mod.rs
similarity index 100%
rename from registry/nacos/src/utils/mod.rs
rename to registry-nacos/src/utils/mod.rs
diff --git a/registry/zookeeper/Cargo.toml b/registry-zookeeper/Cargo.toml
similarity index 68%
rename from registry/zookeeper/Cargo.toml
rename to registry-zookeeper/Cargo.toml
index a6687d9..f83283b 100644
--- a/registry/zookeeper/Cargo.toml
+++ b/registry-zookeeper/Cargo.toml
@@ -10,8 +10,8 @@
[dependencies]
zookeeper = "0.7.0"
-dubbo.workspace = true
-serde_json.workspace = true
-serde = { workspace = true, features = ["derive"] }
-urlencoding.workspace = true
-logger.workspace = true
+dubbo = {path = "../dubbo/", version = "0.3.0" }
+serde_json = "1.0"
+serde = {version = "1.0.145",features = ["derive"]}
+tracing = "0.1"
+urlencoding = "2.1.2"
diff --git a/registry/zookeeper/LICENSE b/registry-zookeeper/LICENSE
similarity index 100%
rename from registry/zookeeper/LICENSE
rename to registry-zookeeper/LICENSE
diff --git a/registry/zookeeper/src/lib.rs b/registry-zookeeper/src/lib.rs
similarity index 100%
rename from registry/zookeeper/src/lib.rs
rename to registry-zookeeper/src/lib.rs
diff --git a/registry/zookeeper/src/zookeeper_registry.rs b/registry-zookeeper/src/zookeeper_registry.rs
similarity index 98%
rename from registry/zookeeper/src/zookeeper_registry.rs
rename to registry-zookeeper/src/zookeeper_registry.rs
index 9f7447b..b31d25c 100644
--- a/registry/zookeeper/src/zookeeper_registry.rs
+++ b/registry-zookeeper/src/zookeeper_registry.rs
@@ -24,8 +24,8 @@
time::Duration,
};
-use logger::tracing::{debug, error, info};
use serde::{Deserialize, Serialize};
+use tracing::{error, info};
#[allow(unused_imports)]
use zookeeper::{Acl, CreateMode, WatchedEvent, WatchedEventType, Watcher, ZooKeeper};
@@ -52,7 +52,7 @@
struct LoggingWatcher;
impl Watcher for LoggingWatcher {
fn handle(&self, e: WatchedEvent) {
- info!("{:?}", e)
+ println!("{:?}", e)
}
}
@@ -240,7 +240,7 @@
impl Registry for ZookeeperRegistry {
fn register(&mut self, url: Url) -> Result<(), StdError> {
- debug!("register url: {}", url);
+ println!("register url: {}", url);
let zk_path = format!(
"/{}/{}/{}/{}",
DUBBO_KEY,
diff --git a/registry/Cargo.toml b/registry/Cargo.toml
new file mode 100644
index 0000000..3325fa8
--- /dev/null
+++ b/registry/Cargo.toml
@@ -0,0 +1,11 @@
+[package]
+name = "registry"
+version = "0.3.0"
+edition = "2021"
+license = "Apache-2.0"
+description = "dubbo-rust-registry"
+repository = "https://github.com/apache/dubbo-rust.git"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
diff --git a/registry/nacos/LICENSE b/registry/LICENSE
similarity index 100%
copy from registry/nacos/LICENSE
copy to registry/LICENSE
diff --git a/registry/src/lib.rs b/registry/src/lib.rs
new file mode 100644
index 0000000..3e01853
--- /dev/null
+++ b/registry/src/lib.rs
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#[cfg(test)]
+mod tests {
+ #[test]
+ fn it_works() {
+ let result = 2 + 2;
+ assert_eq!(result, 4);
+ }
+}