acts-channel

Crates.ioacts-channel
lib.rsacts-channel
version0.4.0
sourcesrc
created_at2024-02-20 13:45:36.550295
updated_at2024-05-21 14:20:54.042848
descriptionacts client channel for acts-server
homepagehttps://github.com/yaojianpin/acts-channel
repositoryhttps://github.com/yaojianpin/acts-channel.git
max_upload_size
id1146406
size57,209
(yaojianpin)

documentation

https://github.com/yaojianpin/acts-channel

README

acts-channel

Build

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

Usage

Before connecting, please download acts-server and start it

Message

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

Action

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

Deploy

let resp = client
    .deploy("mid", "model yml here").await?;
let result: ActionResult = resp.into_inner();

Start

let mut vars = Vars::new();
vars.insert("var1", &true.into());
let resp = client
    .submit("pid", "tid", &vars).await?;
let result: ActionResult = resp.into_inner();

Complete

let mut vars = Vars::new();
vars.insert("var1", json!("value1"));
let resp = client
    .complete("pid", "tid", &vars).await?;
let result: ActionResult = resp.into_inner();

Back

let mut vars = Vars::new();
vars.insert("to", &json!("step1"));
let resp = client
    .back("pid", "tid", &vars).await?;
let result: ActionResult = resp.into_inner();

Cancel

let mut vars = Vars::new();
vars.insert("var1", json!("value1"));
let resp = client
    .cancel("pid", "tid", &vars).await?;
let result: ActionResult = resp.into_inner();

Skip

let mut vars = Vars::new();
vars.insert("var1", json!("value1"));
let resp = client
    .skip("pid", "tid", &vars).await?;
let result: ActionResult = resp.into_inner();

Error

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();

Push

let mut vars = Vars::new();
vars.insert("var1", json!("value1"));
let resp = client
    .push("pid", "tid", &vars).await?;
let result: ActionResult = resp.into_inner();

Remove

let mut vars = Vars::new();
vars.insert("var1", json!("value1"));
let resp = client
    .remove("pid", "tid", &vars).await?;
let result: ActionResult = resp.into_inner();

Commit count: 11

cargo fmt