Crates.io | acts-channel |
lib.rs | acts-channel |
version | 0.4.0 |
source | src |
created_at | 2024-02-20 13:45:36.550295 |
updated_at | 2024-05-21 14:20:54.042848 |
description | acts client channel for acts-server |
homepage | https://github.com/yaojianpin/acts-channel |
repository | https://github.com/yaojianpin/acts-channel.git |
max_upload_size | |
id | 1146406 |
size | 57,209 |
provides an acts client channel for workflow engine server acts-server
The crate is called acts-channel and you can depend on it via cargo:
[dependencies]
acts-channel = "*"
If you want to use the git version:
[dependencies]
acts-channel = { git = "https://github.com/yaojianpin/acts-channel.git" }
Before connecting, please download acts-server
and start it
Listening to the message from acts-server
use acts_channel::{ActsChannel, ActsOptions};
fn on_message(msg: &Message) {
// do something
}
let uri = format!("http://{hostname}:{port}");
let client = ActsChannel::new(
&uri,
"my_client_id",
// the ActsOptions can set to filter the messages with type, event, tag and key
ActsOptions {
on_message: Some(on_message),
..ActsOptions::default()
},
)
.await
Executes action to interact with acts-server, such as deploy
, start
, push
, remove
, submit
, complete
, back
, cancel
, skip
, error
, etc. For more information, please see acts-server
let resp = client
.deploy("mid", "model yml here").await?;
let result: ActionResult = resp.into_inner();
let mut vars = Vars::new();
vars.insert("var1", &true.into());
let resp = client
.submit("pid", "tid", &vars).await?;
let result: ActionResult = resp.into_inner();
let mut vars = Vars::new();
vars.insert("var1", json!("value1"));
let resp = client
.complete("pid", "tid", &vars).await?;
let result: ActionResult = resp.into_inner();
let mut vars = Vars::new();
vars.insert("to", &json!("step1"));
let resp = client
.back("pid", "tid", &vars).await?;
let result: ActionResult = resp.into_inner();
let mut vars = Vars::new();
vars.insert("var1", json!("value1"));
let resp = client
.cancel("pid", "tid", &vars).await?;
let result: ActionResult = resp.into_inner();
let mut vars = Vars::new();
vars.insert("var1", json!("value1"));
let resp = client
.skip("pid", "tid", &vars).await?;
let result: ActionResult = resp.into_inner();
let mut vars = Vars::new();
vars.insert("error_code", json!("err1"));
let resp = client
.error("pid", "tid", &vars).await?;
let result: ActionResult = resp.into_inner();
let mut vars = Vars::new();
vars.insert("var1", json!("value1"));
let resp = client
.push("pid", "tid", &vars).await?;
let result: ActionResult = resp.into_inner();
let mut vars = Vars::new();
vars.insert("var1", json!("value1"));
let resp = client
.remove("pid", "tid", &vars).await?;
let result: ActionResult = resp.into_inner();