yang20150702 commented on code in PR #105:
URL: https://github.com/apache/dubbo-rust/pull/105#discussion_r1098745781
##########
dubbo/src/cluster/loadbalance/types.rs:
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
Review Comment:
可以把LoadBalance接口迁移到mod.rs下
##########
dubbo/src/invocation.rs:
##########
@@ -83,6 +85,13 @@ pub struct Response<T> {
metadata: Metadata,
}
+pub trait RpcResult {}
+
+/// symbol for cluster invoke
+impl<T> RpcResult for Response<T> {}
+
+pub type BoxRpcResult = Box<dyn RpcResult>;
Review Comment:
RpcResult的作用是什么?
##########
config/src/protocol.rs:
##########
@@ -29,7 +31,14 @@ pub struct ProtocolConfig {
pub params: HashMap<String, String>,
}
-impl ProtocolConfig {
+pub type ProtocolConfig = HashMap<String, Protocol>;
Review Comment:
这个接口设计冗余,建议去掉。protocol的默认值可以用const,使用unwrap_or()
##########
dubbo/src/cluster/support/cluster_invoker.rs:
##########
@@ -0,0 +1,156 @@
+/*
+ * 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.
+ */
+
+use std::str::FromStr;
+use std::sync::Arc;
+
+use http::uri::PathAndQuery;
+use http::Request;
+use hyper::Body;
+use tower_service::Service;
+
+use crate::cluster::loadbalance::types::BoxLoadBalance;
+use crate::cluster::loadbalance::LOAD_BALANCE_EXTENSIONS;
+use crate::cluster::support::DEFAULT_LOADBALANCE;
+use crate::codegen::{Directory, RegistryDirectory, TripleClient};
+use crate::common::url::Url;
+use crate::invocation::RpcInvocation;
+use crate::triple;
+
+#[derive(Debug, Clone)]
+pub struct ClusterInvoker {
+ directory: Arc<RegistryDirectory>,
+ destroyed: bool,
+}
+
+pub trait ClusterInvokerSelector {
+ /// Select a invoker using loadbalance policy.
+ fn select(
+ &self,
+ invocation: Arc<RpcInvocation>,
+ invokers: Arc<Vec<Url>>,
+ excluded: Arc<Vec<Url>>,
+ ) -> Option<Url>;
+
+ fn do_select(
+ &self,
+ loadbalance_key: Option<&str>,
+ invocation: Arc<RpcInvocation>,
+ invokers: Arc<Vec<Url>>,
+ ) -> Option<Url>;
+}
+
+pub trait ClusterRequestBuilder<T>
+where
+ T: Service<http::Request<hyper::Body>, Response =
http::Response<crate::BoxBody>>,
+ T::Error: Into<crate::Error>,
+{
+ fn build_req(
Review Comment:
build_req不应该和底层的协议层强绑定。trait需要重新设计一下
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]