async-recipe is a Rust library designed to manage and compose asynchronous workflows using recipe-like patterns. It simplifies the creation and management of complex asynchronous operations by organizing them into clear, reusable steps.
- Define workflows as modular 'recipes' with clear steps.
- Support for retry logic, branching, and conditional execution within workflows.
- Integration with common async frameworks and runtimes like Tokio or async-std.
Add async-recipe to your Cargo.toml:
[dependencies]
async-recipe = "0.1"Below is an example of defining and executing a simple workflow:
use async_recipe::workflow::{Workflow, Step};
use tokio;
#[tokio::main]
async fn main() {
let step1 = Step::new("Fetch Data", async {
// Simulate data fetching
println!("Fetching data...");
Ok("data fetched")
});
let step2 = Step::new("Process Data", async move |data: String| {
println!("Processing: {}", data);
Ok(format!("processed_{}", data))
});
let workflow = Workflow::new(vec![step1, step2]);
match workflow.execute().await {
Ok(result) => println!("Workflow successful: {:?}", result),
Err(err) => println!("Workflow failed: {:?}", err),
}
}-
Steps: Atomic units of your workflow, encapsulating a single piece of logic or functionality. Steps can depend on results from other steps.
-
Workflows: A composition of steps that are executed in sequence. Supports retries, conditions, and branching.
-
Integration: Works seamlessly with Tokio and other async runtimes.
For more details, refer to the documentation.
Contributions are welcome, whether they're bug fixes, new features, or improvements to the documentation.
- Fork the repository.
- Create your feature branch (
git checkout -b feature/my-feature). - Commit your changes (
git commit -m 'feature: add my feature'). - Push to the branch (
git push origin feature/my-feature). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.