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/12/06 10:17:53 UTC

[GitHub] [dubbo-rust] daedalus2022 commented on a diff in pull request #83: Rpc context implementation #58

daedalus2022 commented on code in PR #83:
URL: https://github.com/apache/dubbo-rust/pull/83#discussion_r1040767075


##########
dubbo/src/context.rs:
##########
@@ -96,16 +96,17 @@ mod tests {
 
         let mut handles = Vec::with_capacity(10);
 
-        for i in 0..10 {
+        for i in 0..=10 {
             handles.push(rt.spawn(async move {
-                let mut attachments = RpcContext::current().attachments;
-                attachments.insert("key1".into(), Arc::new(format!("data-{i}")));
-
-                if i == 10 {
-                    attachments.insert("key2".into(), Arc::new(2));
-                    assert_eq!(attachments.len(), 2);
-                } else {
-                    assert_eq!(attachments.len(), 1);
+                let attachments = RpcContext::get_attachments();
+                match attachments {
+                    Some(at) => {
+                        let mut attachments = at.lock().unwrap();
+                        attachments.insert("key1".into(), Arc::new(format!("data-{i}")));
+

Review Comment:
   已修复,谢谢



##########
dubbo/src/context.rs:
##########
@@ -96,16 +96,17 @@ mod tests {
 
         let mut handles = Vec::with_capacity(10);
 
-        for i in 0..10 {
+        for i in 0..=10 {
             handles.push(rt.spawn(async move {
-                let mut attachments = RpcContext::current().attachments;
-                attachments.insert("key1".into(), Arc::new(format!("data-{i}")));
-
-                if i == 10 {
-                    attachments.insert("key2".into(), Arc::new(2));
-                    assert_eq!(attachments.len(), 2);
-                } else {
-                    assert_eq!(attachments.len(), 1);
+                let attachments = RpcContext::get_attachments();
+                match attachments {

Review Comment:
   已修复,谢谢



-- 
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