| Crates.io | orka |
| lib.rs | orka |
| version | 0.1.0 |
| created_at | 2025-05-18 00:13:31.890324+00 |
| updated_at | 2025-05-18 00:13:31.890324+00 |
| description | An asynchronous, pluggable, and type-safe workflow engine for Rust, designed for orchestrating complex multi-step business processes. |
| homepage | https://github.com/excsn/orka |
| repository | https://github.com/excsn/orka |
| max_upload_size | |
| id | 1678243 |
| size | 282,114 |
Orka is an asynchronous, pluggable, and type-safe workflow engine for Rust, designed to orchestrate complex multi-step business processes with robust context management and conditional logic. It simplifies the development of intricate, stateful workflows by providing a clear structure for defining steps, managing shared data, handling errors consistently, and enabling dynamic execution paths, thereby improving code organization and maintainability for complex operations.
Pipeline<TData, Err>) generic over shared context data (TData) and a specific error type (Err), ensuring compile-time safety throughout your process.async fn handlers, perfect for non-blocking I/O and efficient resource use.ContextData<T> (Arc<RwLock<T>>) for safe, shared, and mutable access to pipeline state across handlers, with enforced lock guard discipline.ConditionalScopeBuilder to define dynamic branching, executing isolated sub-pipelines (Pipeline<SData, Err>) based on runtime conditions. Supports dynamic or static sourcing of these scoped pipelines.OrkaError can be seamlessly converted (via From<OrkaError>).SData) of the main pipeline's context (TData) through extractors.Orka<ApplicationError> type-keyed registry.Add Orka to your Cargo.toml dependencies:
[dependencies]
orka = "0.1.0" # Replace with the latest version from crates.io
tokio = { version = "1", features = ["full"] } # Orka requires a Tokio runtime
# Add other necessary crates like tracing, serde, thiserror, etc.
MyWorkflowData).From<orka::OrkaError>.orka::Pipeline<MyWorkflowData, MyAppError>::new(...) with named steps.pipeline.on_root(...) to attach asynchronous logic to steps.
use orka::{Pipeline, ContextData, PipelineControl, OrkaError};
use std::sync::Arc;
#[derive(Clone, Default)]
struct MyContext { count: i32 }
#[derive(Debug, thiserror::Error)]
enum MyError { #[error(transparent)] Orka(#[from] OrkaError), /* ... */ }
let mut pipeline = Pipeline::<MyContext, MyError>::new(&[("step1", false, None)]);
pipeline.on_root("step1", |ctx: ContextData<MyContext>| Box::pin(async move {
ctx.write().count += 1;
Ok(PipelineControl::Continue)
}));
pipeline.conditional_scopes_for_step(...) for branching.orka::Orka<MyAppError> instance and register your pipeline(s).# async {
# use orka::{Pipeline, ContextData, PipelineControl, OrkaError, Orka, PipelineResult};
# #[derive(Clone, Default)] struct MyContext { count: i32 }
# #[derive(Debug, thiserror::Error)] enum MyError { #[error(transparent)] Orka(#[from] OrkaError),}
# let mut pipeline = Pipeline::<MyContext, MyError>::new(&[("step1", false, None)]);
# pipeline.on_root("step1", |ctx: ContextData<MyContext>| Box::pin(async move { Ok(PipelineControl::Continue) }));
let initial_data = ContextData::new(MyContext::default());
let outcome = pipeline.run(initial_data.clone()).await;
// Or, if using the registry:
// let orka_registry = Orka::<MyError>::new();
// orka_registry.register_pipeline(pipeline);
// let outcome = orka_registry.run(initial_data.clone()).await;
match outcome {
Ok(PipelineResult::Completed) => println!("Pipeline completed! Count: {}", initial_data.read().count),
Ok(PipelineResult::Stopped) => println!("Pipeline stopped."),
Err(e) => println!("Pipeline failed: {:?}", e),
}
# };
examples/): Check out the ecommerce_app for a practical application of Orka.Contributions are highly welcome! Whether it's bug reports, feature suggestions, documentation improvements, or code contributions, please feel free to open an issue or pull request on GitHub.
Orka is distributed under the terms of the Mozilla Public License, v. 2.0.
A copy of the license is available in the LICENSE file, or at http://mozilla.org/MPL/2.0/.