Skip to content

Commit

Permalink
Merge pull request #17 from CoLearn-Dev/0.1.20
Browse files Browse the repository at this point in the history
- update proto
  • Loading branch information
stneng authored Oct 11, 2022
2 parents 5c4ef26 + bc6f0c0 commit c014202
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "colink"
version = "0.1.19"
version = "0.1.20"
edition = "2021"
description = "CoLink Rust SDK"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion examples/user_start_protocol_operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>
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, false)
.await?;
println!("Instance id: {}", instance_id);

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion proto
Submodule proto updated 1 files
+31 −7 colink.proto
8 changes: 4 additions & 4 deletions src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,14 +419,15 @@ impl CoLink {
&self,
protocol_name: &str,
user_id: &str,
upgrade: bool,
) -> Result<String, Error> {
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?;
Expand All @@ -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?;
Expand Down
8 changes: 4 additions & 4 deletions src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -188,14 +188,14 @@ pub fn _protocol_start(
}
cl.unlock(lock).await?;
Ok::<(), Box<dyn std::error::Error + Send + Sync + 'static>>(())
});
})?;
} 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()
Expand All @@ -206,7 +206,7 @@ pub fn _protocol_start(
cl_clone.update_entry(&is_initialized_key, &[1]).await?;
}
Ok::<(), Box<dyn std::error::Error + Send + Sync + 'static>>(())
});
})?;
for (protocol_and_role, user_func) in operator_funcs {
let cl = cl.clone();
thread::spawn(|| {
Expand Down

0 comments on commit c014202

Please sign in to comment.