Crates.io | orchestrator |
lib.rs | orchestrator |
version | 0.2.2 |
source | src |
created_at | 2020-11-09 23:50:10.834873 |
updated_at | 2023-06-22 21:02:25.52239 |
description | Orchestration sequences |
homepage | |
repository | https://github.com/elasticrash/orchestrator.git |
max_upload_size | |
id | 310523 |
size | 9,468 |
The orchestration library is designed to streamline and manage complex workflows by providing a framework for orchestrating and sequencing functions in a controlled manner. It allows developers to define a series of state functions and execute them in a predefined order, passing data between each step. With the ability to handle various types, the library offers flexibility in processing different data structures.
To define an orchestration function, you can utilize the state_function! macro. Here's an example:
let fn1: fn(State<f32>) -> Result<State<f32>, Error> =
state_function!(pow2, f32);
A state is represented by the following structure:
pub struct State<T> {
pub proceed: bool,
pub outcome: Option<T>,
pub stage: Vec<bool>,
}
In some cases, you can directly utilize the orchestration by employing the following approach:
let result = vec![fn1, fn2, fn3]
.execute(State {
proceed: true,
outcome: Some(6.),
stage: Vec::<bool>::new(),
});
Alternatively, you can use the registration trait to assign string names to the orchestration functions. This approach proves useful when configuring function sequences more generically:
registry.register(fn1, "pow2".to_string());
registry.register(fn2, "pow3".to_string());
registry.register(fn3, "sqrt".to_string());
let result = vec!["pow2", "pow3", "sqrt"]
.create(®istry.di_ref)
.execute(State {
proceed: true,
outcome: Some(6.),
stage: Vec::<bool>::new(),
});
By assigning values to the stage, as shown in the example below, you can bypass specific steps in the sequence. Marking a step as true allows it to be skipped:
stage: vec![true, true, false, false],
For a more intricate example, please refer to the following link: https://github.com/elasticrash/keyboard/blob/master/lib/src/geometry/exported_geometry.rs