pub struct Engine { /* private fields */ }Expand description
Workflow Engine
§Example:
a example to caculate the result from 1 to given input value
use acts::{Engine, Workflow, Vars};
#[tokio::main]
async fn main() {
let engine = Engine::new();
let model = include_str!("../examples/simple/model.yml");
let workflow = Workflow::from_yml(model).unwrap();
engine.channel().on_complete(|e| {
println!("{:?}", e.outputs);
});
let exec = engine.executor();
exec.model().deploy(&workflow).expect("fail to deploy workflow");
let mut vars = Vars::new();
vars.insert("input".into(), 3.into());
vars.insert("pid".into(), "test1".into());
exec.proc().start(
&workflow.id,
&vars);
}Implementations§
Source§impl Engine
impl Engine
pub fn new() -> Self
pub fn config(&self) -> Arc<Config>
Sourcepub fn channel_with_options(&self, matcher: &ChannelOptions) -> Arc<Channel>
pub fn channel_with_options(&self, matcher: &ChannelOptions) -> Arc<Channel>
create named channel to receive messages
if setting the emit_id by ChannelOptions it will check the status and re-send when not acking
§Example
use acts::{ Engine, ChannelOptions };
let engine = Engine::new();
let chan = engine.channel_with_options(&ChannelOptions { id: "chan1".to_string(), ack: true, r#type: "step".to_string(), key: "my_key*".to_string(), state: "{created, completed}".to_string(), tag: "*".to_string() });
chan.on_message(|e| {
// do something
});Sourcepub fn close(&self)
pub fn close(&self)
close engine
§Example
use acts::{Engine, Workflow, Vars};
#[tokio::main]
async fn main() {
let engine = Engine::new();
engine.close();
}pub fn signal<T: Clone>(&self, init: T) -> Signal<T>
pub fn is_running(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Engine
impl !RefUnwindSafe for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl !UnwindSafe for Engine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more