Skip to content

Commit ed8d438

Browse files
committed
Merge branch 'develop'
2 parents 252a053 + 2a54887 commit ed8d438

131 files changed

Lines changed: 3149 additions & 1745 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,30 @@
114114
- feat: modify Config to support getting custom config section
115115
- feat: add workflow.on events (manual, hook, chat)
116116
- feat: add acts-state package to support get or set state
117-
- feat: change the directory structure with acts, plugins, examples, benches, config
117+
- feat: change the directory structure with acts, plugins, examples, benches, config
118+
119+
# 0.17.0
120+
- feat: reactoring env module to add register_var trait
121+
- feat: add "resects" user var to support get resects data from task context
122+
- feat: add step env module to support get step vars by step id
123+
- feat: change env var to $env
124+
- feat: rename proc env_local to env
125+
- feat: change event package params to Option<T>
126+
- feat: skip initialization of plugin when there is no related section
127+
- feat: add `acts.core.http` package plugin
128+
- feat: add `pid` prefix to the acts.app.state package
129+
- feat: support private vars (starts with `__`)
130+
- feat: use `acts.toml` instead of `acts.cfg`
131+
- feat: add `env.expose` in workflow to support set default outputs, the default outputs is `data`
132+
- feat: add `acts.app.shell` package plugin to support nushell, bash and powershell
133+
support {{ }} refs the var in shell script
134+
- feat: add `os` var in expression
135+
- feat: use {{ }} for expression instead of ${ }
136+
- feat: use var name directly in script or expression instead of $("var")
137+
use $get("var") instead of $("var")
138+
use $set("var", value) instead of $("var", value)
139+
use $inputs() instead of $act.inputs()
140+
use $data() instead of $act.data()
141+
142+
# 0.17.1
143+
- fix: fix examples/plugins build issue when exclude examples

Cargo.toml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,35 @@ members = [
55
"store/sqlite",
66
"store/postgres",
77
"plugins/state",
8+
"plugins/http",
89
"examples/plugins/*",
10+
"plugins/shell",
11+
]
12+
exclude = [
13+
"examples/plugins/state",
14+
"examples/plugins/http",
15+
"examples/plugins/shell",
916
]
10-
exclude = ["examples/plugins/state"]
1117
resolver = "3"
1218

19+
[workspace.package]
20+
authors = ["Yao <yaojianpin@sohu.com>"]
21+
description = "a fast, lightweight, extensiable workflow engine"
22+
keywords = ["workflow"]
23+
edition = "2024"
24+
license = "Apache-2.0"
25+
repository = "https://github.com/yaojianpin/acts.git"
26+
version = "0.17.1"
27+
1328
[workspace.dependencies]
14-
tokio = { version = "1.44" }
29+
tokio = { version = "1.44", features = ["full"] }
1530
async-trait = { version = "0.1.88" }
31+
serde = "1.0.219"
32+
serde_json = "1.0.140"
33+
strum = { version = "0.27", features = ["derive"] }
34+
35+
[profile.release]
36+
codegen-units = 1
37+
lto = true
38+
opt-level = "z"
39+
strip = true

README.md

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,41 @@ use acts::{Engine, Vars, Workflow};
5959
async fn main() {
6060
let engine = Engine::new().start();
6161
62-
let text = include_str!("../../examples/simple/model.yml");
63-
let workflow = Workflow::from_yml(text).unwrap();
62+
// create yaml workflow model
63+
let model = r#"
64+
id: my_model
65+
name: my model
66+
outputs:
67+
a:
68+
steps:
69+
- name: step 1
70+
acts:
71+
- uses: acts.transform.set
72+
params:
73+
a: 10
74+
- name: step 2
75+
acts:
76+
- uses: acts.transform.code
77+
params: |
78+
return { a: a + 10 };
79+
"#;
80+
let workflow = Workflow::from_yml(model).unwrap();
6481
6582
let executor = engine.executor();
6683
executor.model().deploy(&workflow).expect("fail to deploy workflow");
6784
6885
let mut vars = Vars::new();
69-
vars.insert("input".into(), 3.into());
86+
87+
// set the input value
88+
vars.insert("a".into(), 0.into());
89+
90+
// set the pid or auto generate by engine
7091
vars.insert("pid".to_string(), "w1".into());
71-
executor.proc().start(&workflow.id, &vars).expect("fail to start workflow");;
92+
93+
// start workflow by model id
94+
executor.proc().start(&workflow.id, &vars).expect("fail to start workflow");
95+
96+
// create channel to receive messages
7297
let chan = engine.channel();
7398
7499
chan.on_start(|e| {
@@ -123,22 +148,22 @@ steps:
123148
# workflow branches to run by condition
124149
branches:
125150
- name: branch 1
126-
if: ${ $("value") > 100 }
151+
if: value > 100
127152
steps:
128153
- name: step 3
129154
acts:
130155
- name: send a message
131156
uses: acts.core.msg
132157

133158
- name: branch 2
134-
if: ${ $("value") <= 100 }
159+
if: value <= 100
135160
steps:
136161
- name: step 4
137162
acts:
138163
- name: parallel send irq request
139164
uses: acts.core.parallel
140165
params:
141-
in: ${ ${list} }
166+
in: '{{ list }}'
142167
acts:
143168
- uses: acts.core.irq
144169
- name: final step
@@ -155,8 +180,12 @@ inputs:
155180
a: 100
156181
steps:
157182
- name: step1
158-
run: |
159-
$("output_key", "output value");
183+
acts:
184+
- uses: acts.transform.code
185+
params: |
186+
// get the a variable
187+
let v = a + 100;
188+
// do somthing else
160189
```
161190
162191
The inputs can also be set by starting the workflow.
@@ -187,8 +216,12 @@ outputs:
187216
output_key:
188217
steps:
189218
- name: step1
190-
run: |
191-
$("output_key", "output value");
219+
acts:
220+
- uses: acts.transform.set
221+
params:
222+
output_key: 100
223+
outputs:
224+
output_key:
192225
```
193226
194227
### Setup
@@ -201,13 +234,15 @@ For more acts, please see the comments as follow:
201234
```yml
202235
name: model name
203236
steps:
204-
- uses: acts.core.set
205-
params:
206-
a: ['u1', 'u2']
207-
v: 10
208-
- uses: acts.core.msg
209-
if: $("v") > 0
210-
key: msg1
237+
- name: step 1
238+
acts:
239+
- uses: acts.transform.set
240+
params:
241+
a: ['u1', 'u2']
242+
v: 10
243+
- uses: acts.core.msg
244+
if: v > 0
245+
key: msg1
211246
setup:
212247
# on step created
213248
- uses: acts.core.msg
@@ -385,7 +420,7 @@ steps:
385420
name: step 1
386421
branches:
387422
- id: b1
388-
if: $("v") > 0
423+
if: v > 0
389424
steps:
390425
- name: step a
391426
- name: step b
@@ -503,7 +538,6 @@ acts:
503538
- [x] parallel
504539
- [x] sequence
505540
- [x] subflow
506-
- [ ] http
507541

508542
- event
509543
- [x] manual
@@ -514,7 +548,6 @@ acts:
514548
- transform
515549
- [x] set
516550
- [x] code
517-
- [ ] split
518551

519552
- [ ] doc (doc/)
520553

@@ -527,6 +560,8 @@ acts:
527560
- [ ] form (plugins/form)
528561
- [ ] ai (plugins/ai)
529562
- [x] state (plugins/state)
563+
- [x] http (plugins/http)
564+
- [x] shell (plugins/shell) support nushell, bash and powershell
530565
- [ ] pubsub (plugins/pubsub)
531566
- [ ] observability (plugins/obs)
532567
- [ ] database (plugins/database)

acts/Cargo.toml

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,28 @@ license = "Apache-2.0"
88
name = "acts"
99
homepage = "https://docs.rs/acts"
1010
repository = "https://github.com/yaojianpin/acts.git"
11-
version = "0.16.1"
11+
version = "0.17.0"
1212
include = ["src/**/*", "../LICENSE", "../README.md", "!**/tests/**/*"]
1313

1414
[dependencies]
15-
tokio = { features = ["full"], workspace = true }
15+
tokio = { features = ["full", "macros"], workspace = true }
1616
async-trait = { workspace = true }
1717
chrono = { version = "0.4" }
1818
globset = { version = "0.4", default-features = false }
19-
hocon = { version = "0.9.0", default-features = false, features = [
20-
"serde-support",
21-
] }
2219
inventory = "0.3.20"
2320
jsonschema = { version = "0.30.0", default-features = false }
2421
moka = { version = "0.12", features = ["sync"] }
2522
nanoid = "0.4"
2623
regex = "1.10"
2724
rquickjs = { version = "0.9", features = ["full", "parallel"] }
28-
serde = { version = "1.0", features = ["derive"] }
29-
serde_json = "1.0"
25+
serde = { features = ["derive"], workspace = true }
26+
serde_json = { workspace = true }
3027
serde_repr = "0.1"
3128
serde_yaml = "0.9"
32-
strum = { version = "0.27", features = ["derive"] }
29+
strum = { features = ["derive"], workspace = true }
3330
thiserror = "2"
3431
tracing = "0.1"
32+
toml = "0.8.22"
3533

3634
[dev-dependencies]
3735
criterion = { version = "0.5", features = ["async_tokio"] }
@@ -44,6 +42,50 @@ harness = false
4442
name = "workflow"
4543
path = "../benches/workflow.rs"
4644

45+
[[example]]
46+
name = "simple"
47+
path = "../examples/simple/main.rs"
48+
49+
[[example]]
50+
name = "model_build"
51+
path = "../examples/model_build/main.rs"
52+
53+
[[example]]
54+
name = "actions"
55+
path = "../examples/actions/main.rs"
56+
57+
[[example]]
58+
name = "approve"
59+
path = "../examples/approve/main.rs"
60+
61+
[[example]]
62+
name = "catches"
63+
path = "../examples/catches/main.rs"
64+
65+
[[example]]
66+
name = "event"
67+
path = "../examples/event/main.rs"
68+
69+
[[example]]
70+
name = "message"
71+
path = "../examples/message/main.rs"
72+
73+
[[example]]
74+
name = "package"
75+
path = "../examples/package/main.rs"
76+
77+
[[example]]
78+
name = "subflow"
79+
path = "../examples/subflow/main.rs"
80+
81+
[[example]]
82+
name = "timeout"
83+
path = "../examples/timeout/main.rs"
84+
85+
[[example]]
86+
name = "user_var"
87+
path = "../examples/user_var/main.rs"
88+
4789
[profile.release]
4890
codegen-units = 1
4991
lto = true

acts/src/builder.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#[cfg(test)]
2-
use crate::ConfigData;
3-
use crate::{ActPlugin, Config, Engine, Result};
2+
use crate::config::ConfigData;
3+
use crate::{ActPlugin, Config, Engine, Result, config::ConfigLog};
44
use std::path::Path;
55

66
pub struct EngineBuilder {
@@ -18,10 +18,10 @@ impl EngineBuilder {
1818
pub fn new() -> Self {
1919
let mut config = Config::default();
2020
#[cfg(not(test))]
21-
let file = Path::new("config/acts.cfg");
21+
let file = Path::new("config/acts.toml");
2222

2323
#[cfg(test)]
24-
let file = Path::new("test/acts.cfg");
24+
let file = Path::new("test/acts.toml");
2525

2626
if file.exists() {
2727
config = Config::create(file);
@@ -37,7 +37,7 @@ impl EngineBuilder {
3737
pub fn set_config(mut self, data: &ConfigData) -> Self {
3838
self.config = Config {
3939
data: data.clone(),
40-
table: hocon::Hocon::Null,
40+
table: toml::Table::new(),
4141
};
4242
self
4343
}
@@ -47,28 +47,26 @@ impl EngineBuilder {
4747
self
4848
}
4949

50-
pub fn log_dir(mut self, log_dir: &str) -> Self {
51-
self.config.data.log_dir = log_dir.to_string();
52-
self
53-
}
54-
55-
pub fn log_level(mut self, level: &str) -> Self {
56-
self.config.data.log_level = level.to_string();
50+
pub fn log(mut self, dir: &str, level: &str) -> Self {
51+
self.config.data.log = Some(ConfigLog {
52+
dir: dir.to_string(),
53+
level: level.to_string(),
54+
});
5755
self
5856
}
5957

6058
pub fn cache_size(mut self, size: i64) -> Self {
61-
self.config.data.cache_cap = size;
59+
self.config.data.cache_cap = Some(size);
6260
self
6361
}
6462

6563
pub fn tick_interval_secs(mut self, secs: i64) -> Self {
66-
self.config.data.tick_interval_secs = secs;
64+
self.config.data.tick_interval_secs = Some(secs);
6765
self
6866
}
6967

7068
pub fn max_message_retry_times(mut self, retry_times: i32) -> Self {
71-
self.config.data.max_message_retry_times = retry_times;
69+
self.config.data.max_message_retry_times = Some(retry_times);
7270
self
7371
}
7472

0 commit comments

Comments
 (0)