@@ -59,16 +59,41 @@ use acts::{Engine, Vars, Workflow};
5959async 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
156181steps :
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
162191The inputs can also be set by starting the workflow.
@@ -187,8 +216,12 @@ outputs:
187216 output_key :
188217steps :
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
202235name: model name
203236steps:
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
211246setup:
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)
0 commit comments