Crate pocketflow

Source
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§

async_node
create_async_node
create_node
sync_node

Structs§

AsyncBatchFlow
Asynchronous flow implementations for creating complex data processing pipelines. Async batch flow structure
AsyncBatchNode
Node implementations for both synchronous and asynchronous data processing. Async batch node implementation
AsyncFlow
Asynchronous flow implementations for creating complex data processing pipelines. Async flow structure
AsyncNode
Node implementations for both synchronous and asynchronous data processing. Async node implementation
AsyncParallelBatchFlow
Asynchronous flow implementations for creating complex data processing pipelines. Async parallel batch flow structure
AsyncParallelBatchNode
Node implementations for both synchronous and asynchronous data processing. Async parallel batch node implementation
BatchFlow
Synchronous flow implementations for creating data processing pipelines. Batch flow structure
BatchNode
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§

AsyncBaseNode
Base node traits that define the core behavior of processing nodes. The base trait for all async nodes
BaseNode
Base node traits that define the core behavior of processing nodes. The base trait for all nodes in the flow

Type Aliases§

ActionKey
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
SharedState
Common types and constants used throughout the library. Shared state that can be passed between nodes