Skip to content

m0nirul/async-recipe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

async-recipe

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.

Features

  • 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.

Getting Started

Add async-recipe to your Cargo.toml:

[dependencies]
async-recipe = "0.1"

Example Usage

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),
    }
}

Key Concepts

  1. Steps: Atomic units of your workflow, encapsulating a single piece of logic or functionality. Steps can depend on results from other steps.

  2. Workflows: A composition of steps that are executed in sequence. Supports retries, conditions, and branching.

  3. Integration: Works seamlessly with Tokio and other async runtimes.

For more details, refer to the documentation.

Contributing

Contributions are welcome, whether they're bug fixes, new features, or improvements to the documentation.

  1. Fork the repository.
  2. Create your feature branch (git checkout -b feature/my-feature).
  3. Commit your changes (git commit -m 'feature: add my feature').
  4. Push to the branch (git push origin feature/my-feature).
  5. Open a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

A Rust library to manage and compose asynchronous workflows using recipe-like patterns.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages