From ffd3dff31e1cca8b3cd4c35912c19edcf4583b4b Mon Sep 17 00:00:00 2001 From: stneng Date: Tue, 11 Oct 2022 00:02:26 +0000 Subject: [PATCH 1/3] update proto --- Cargo.toml | 2 +- README.md | 2 +- examples/user_start_protocol_operator.rs | 4 +++- proto | 2 +- src/application.rs | 8 ++++---- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3f9e7a0..a011bff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "colink" -version = "0.1.19" +version = "0.1.20" edition = "2021" description = "CoLink Rust SDK" license = "MIT" diff --git a/README.md b/README.md index 74b9a38..323dda6 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ CoLink SDK helps both application adnd protocol developers access the functional Add this to your Cargo.toml: ```toml [dependencies] -colink = "0.1.19" +colink = "0.1.20" ``` ## Getting Started diff --git a/examples/user_start_protocol_operator.rs b/examples/user_start_protocol_operator.rs index 3f9b40c..5476852 100644 --- a/examples/user_start_protocol_operator.rs +++ b/examples/user_start_protocol_operator.rs @@ -9,7 +9,9 @@ async fn main() -> Result<(), Box let protocol_name = &args[2]; let user_id = decode_jwt_without_validation(jwt).unwrap().user_id; let cl = CoLink::new(addr, jwt); - let instance_id = cl.start_protocol_operator(protocol_name, &user_id).await?; + let instance_id = cl + .start_protocol_operator(protocol_name, &user_id, true) + .await?; println!("Instance id: {}", instance_id); Ok(()) diff --git a/proto b/proto index 224245a..a322f83 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 224245ae7bb372cdaff54bdf6b5ea84846e5348b +Subproject commit a322f83c2fa0f74127531728394a1ea24acbe8ab diff --git a/src/application.rs b/src/application.rs index 2b76d23..470005e 100644 --- a/src/application.rs +++ b/src/application.rs @@ -419,14 +419,15 @@ impl CoLink { &self, protocol_name: &str, user_id: &str, + upgrade: bool, ) -> Result { let mut client = self._grpc_connect(&self.core_addr).await?; let request = generate_request( &self.jwt, - ProtocolOperatorInstance { + StartProtocolOperatorRequest { protocol_name: protocol_name.to_string(), user_id: user_id.to_string(), - ..Default::default() + upgrade, }, ); let response = client.start_protocol_operator(request).await?; @@ -438,9 +439,8 @@ impl CoLink { let mut client = self._grpc_connect(&self.core_addr).await?; let request = generate_request( &self.jwt, - ProtocolOperatorInstance { + ProtocolOperatorInstanceId { instance_id: instance_id.to_string(), - ..Default::default() }, ); let response = client.stop_protocol_operator(request).await?; From cd82b1aed2659e2d94b3515dfa0496c42a231afb Mon Sep 17 00:00:00 2001 From: stneng Date: Tue, 11 Oct 2022 00:04:27 +0000 Subject: [PATCH 2/3] update examples --- examples/user_start_protocol_operator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/user_start_protocol_operator.rs b/examples/user_start_protocol_operator.rs index 5476852..bb3c2a2 100644 --- a/examples/user_start_protocol_operator.rs +++ b/examples/user_start_protocol_operator.rs @@ -10,7 +10,7 @@ async fn main() -> Result<(), Box let user_id = decode_jwt_without_validation(jwt).unwrap().user_id; let cl = CoLink::new(addr, jwt); let instance_id = cl - .start_protocol_operator(protocol_name, &user_id, true) + .start_protocol_operator(protocol_name, &user_id, false) .await?; println!("Instance id: {}", instance_id); From bc6f0c004739fd77f2ebc36100607cc863513733 Mon Sep 17 00:00:00 2001 From: stneng Date: Tue, 11 Oct 2022 04:11:39 +0000 Subject: [PATCH 3/3] throw error --- src/protocol.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/protocol.rs b/src/protocol.rs index fd6fc11..e1013fb 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -166,7 +166,7 @@ pub fn _protocol_start( let cl = cl.clone(); if protocol_and_role.ends_with(":@init") { let protocol_name = protocol_and_role[..protocol_and_role.len() - 6].to_string(); - let _ = tokio::runtime::Builder::new_multi_thread() + tokio::runtime::Builder::new_multi_thread() .enable_all() .build() .unwrap() @@ -188,14 +188,14 @@ pub fn _protocol_start( } cl.unlock(lock).await?; Ok::<(), Box>(()) - }); + })?; } else { protocols.push(protocol_and_role[..protocol_and_role.rfind(':').unwrap()].to_string()); operator_funcs.insert(protocol_and_role, user_func); } } let cl_clone = cl.clone(); - let _ = tokio::runtime::Builder::new_multi_thread() + tokio::runtime::Builder::new_multi_thread() .enable_all() .build() .unwrap() @@ -206,7 +206,7 @@ pub fn _protocol_start( cl_clone.update_entry(&is_initialized_key, &[1]).await?; } Ok::<(), Box>(()) - }); + })?; for (protocol_and_role, user_func) in operator_funcs { let cl = cl.clone(); thread::spawn(|| {