#workflow #channel #client #acts #message #engine #acts-server

acts-channel

acts-server 的 acts 客户端通道

4 个版本

0.4.0 2024年5月21日
0.3.2 2024年2月21日
0.3.1 2024年2月20日
0.3.0 2024年2月20日

945解析器实现

MIT 许可证

51KB
1K SLoC

acts-channel

Build

为工作流引擎服务器 acts-server 提供 acts 客户端通道

该crate名为acts-channel,您可以通过cargo依赖它

[dependencies]
acts-channel = "*"

如果您想使用git版本

[dependencies]
acts-channel = { git = "https://github.com/yaojianpin/acts-channel.git" }

用法

在连接之前,请下载并启动 acts-server

消息

监听来自 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

操作

执行与 acts-server 交互的操作,例如 deploystartpushremovesubmitcompletebackcancelskiperror 等。更多信息请见 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();

依赖

~7–9.5MB
~166K SLoC