You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/11/14 12:53:53 UTC

[GitHub] [dubbo-rust] tuchg opened a new pull request, #64: Ftr: add rpc-context

tuchg opened a new pull request, #64:
URL: https://github.com/apache/dubbo-rust/pull/64

   add a base model of RPC Context


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-rust] yang20150702 merged pull request #64: Ftr: add rpc-context (#58)

Posted by GitBox <gi...@apache.org>.
yang20150702 merged PR #64:
URL: https://github.com/apache/dubbo-rust/pull/64


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-rust] yang20150702 commented on a diff in pull request #64: Ftr: add rpc-context (#58)

Posted by GitBox <gi...@apache.org>.
yang20150702 commented on code in PR #64:
URL: https://github.com/apache/dubbo-rust/pull/64#discussion_r1022768220


##########
dubbo/src/lib.rs:
##########
@@ -22,6 +22,7 @@ mod framework;
 pub mod invocation;
 pub mod protocol;
 pub mod registry;
+pub mod rpc;

Review Comment:
   the meaning of rpc name is too big. I suggest that you can use context directly.



##########
dubbo/src/rpc/context.rs:
##########
@@ -0,0 +1,110 @@
+/*
+ * 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 core::cell::RefCell;
+use std::any::Any;
+use std::collections::HashMap;
+use std::fmt;
+use std::sync::Arc;
+
+type SafetyValue = Arc<dyn Any + Sync + Send>;
+thread_local! {
+    static SERVICE_CONTEXT: RefCell<RpcContext> = RefCell::new(RpcContext::default());
+    // from Java
+    // static SERVER_CONTEXT: RefCell<Context> = RefCell::new(Context::default());
+    // static CLIENT_ATTACHMENT: RefCell<Context> = RefCell::new(Context::default());
+    // static SERVER_ATTACHMENT: RefCell<Context> = RefCell::new(Context::default());
+    // static CANCELLATION_CONTEXT: RpcContext = RpcContext::default();
+}
+
+///
+/// All environment information of during the current call will put into the context
+/// on the filter composing process,and all configuration information will convert the parameters of URL instance.
+///
+/// RpcContext is a temporary status recorder of [thread_local],when accept RPC request or send RPC request,
+///  The RpcContext will be changed.Such as: A call B and B call C.
+/// On B machine,before B call C,the RpcContext will record the information of A call B.
+/// After B call C,the RpcContext record the information of B call C
+///
+#[derive(Clone, Default)]
+pub struct RpcContext {
+    pub attachments: HashMap<String, SafetyValue>,

Review Comment:
   how to resolve(downcast) SafetyValue? you can add some unittests



##########
dubbo/src/rpc/context.rs:
##########
@@ -0,0 +1,110 @@
+/*
+ * 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 core::cell::RefCell;
+use std::any::Any;
+use std::collections::HashMap;
+use std::fmt;
+use std::sync::Arc;
+
+type SafetyValue = Arc<dyn Any + Sync + Send>;
+thread_local! {
+    static SERVICE_CONTEXT: RefCell<RpcContext> = RefCell::new(RpcContext::default());
+    // from Java

Review Comment:
   these codes can delete, you can add some comment that describe Why and What



-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-rust] yang20150702 commented on pull request #64: Ftr: add rpc-context (#58)

Posted by GitBox <gi...@apache.org>.
yang20150702 commented on PR #64:
URL: https://github.com/apache/dubbo-rust/pull/64#issuecomment-1319987542

   LGTM


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org