Expand description
§PocketFlow
PocketFlow is a lightweight, composable workflow library for Rust that provides both synchronous and asynchronous execution patterns for data processing pipelines.
§Features
- Composable workflows: Build complex data processing pipelines from simple nodes
- Synchronous and asynchronous support: Choose the execution model that fits your needs
- Batch processing: Process multiple items efficiently
- Parallel execution: Take advantage of multi-core systems
§Examples
§Simple synchronous flow
use pocketflow_rs::{Flow, Node};
use serde_json::json;
// Create a simple processing node
let node = Node::new(|data| {
// Process the data
let result = json!({"processed": data});
Ok(result)
});
// Create a flow with the node
let mut flow = Flow::new();
flow.add_node(node);
// Run the flow with input data
let input = json!({"input": "value"});
let result = flow.run(&input).unwrap();
§Asynchronous flow
use pocketflow_rs::{AsyncFlow, AsyncNode};
use serde_json::json;
// Create an async processing node
let node = AsyncNode::new(|data| {
Box::pin(async move {
// Asynchronous processing
let result = json!({"processed": data});
Ok(result)
})
});
// Create an async flow with the node
let mut flow = AsyncFlow::new();
flow.add_node(node);
// Run the flow with input data
let input = json!({"input": "value"});
let result = flow.run_async(&input).await.unwrap();
Macros§
Structs§
- Async
Batch Flow - Asynchronous flow implementations for creating complex data processing pipelines. Async batch flow structure
- Async
Batch Node - Node implementations for both synchronous and asynchronous data processing. Async batch node implementation
- Async
Flow - Asynchronous flow implementations for creating complex data processing pipelines. Async flow structure
- Async
Node - Node implementations for both synchronous and asynchronous data processing. Async node implementation
- Async
Parallel Batch Flow - Asynchronous flow implementations for creating complex data processing pipelines. Async parallel batch flow structure
- Async
Parallel Batch Node - Node implementations for both synchronous and asynchronous data processing. Async parallel batch node implementation
- Batch
Flow - Synchronous flow implementations for creating data processing pipelines. Batch flow structure
- Batch
Node - Node implementations for both synchronous and asynchronous data processing. A node that processes a batch of items
- Flow
- Synchronous flow implementations for creating data processing pipelines. Flow orchestration structure
- Node
- Node implementations for both synchronous and asynchronous data processing. A node with retry capabilities
Constants§
- DEFAULT_
ACTION - Common types and constants used throughout the library.
Traits§
- Async
Base Node - Base node traits that define the core behavior of processing nodes. The base trait for all async nodes
- Base
Node - Base node traits that define the core behavior of processing nodes. The base trait for all nodes in the flow
Type Aliases§
- Action
Key - Common types and constants used throughout the library. Action string used for determining the next node in a flow
- Params
- Common types and constants used throughout the library. Parameters that can be configured for nodes
- Shared
State - Common types and constants used throughout the library. Shared state that can be passed between nodes