cano 0.6.3

Simple & Fast Async Workflows in Rust - Build data processing pipelines with Tasks and Nodes
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
# Cano: Async Data & AI Workflows in Rust

[![Crates.io](https://img.shields.io/crates/v/cano.svg)](https://crates.io/crates/cano)
[![Documentation](https://docs.rs/cano/badge.svg)](https://docs.rs/cano)
[![Downloads](https://img.shields.io/crates/d/cano.svg)](https://crates.io/crates/cano)
[![License](https://img.shields.io/crates/l/cano.svg)](https://github.com/nassor/cano/blob/main/LICENSE)
[![CI](https://github.com/nassor/cano/workflows/CI/badge.svg)](https://github.com/nassor/cano/actions)

**Async workflow engine with built-in scheduling, retry logic, and state machine semantics.**

Cano is an async workflow engine for Rust that manages complex processing through composable workflows. It can be used for data processing, AI inference workflows, and background jobs. Cano provides a simple, fast and type-safe API for defining workflows with retry strategies, scheduling capabilities, and shared state management.

The engine is built on three core concepts: **Tasks** and **Nodes** to encapsulate business logic, **Workflows** to manage state transitions, and **Schedulers** to run workflows on a schedule.

*The Node API is inspired by the [PocketFlow](https://github.com/The-Pocket/PocketFlow) project, adapted for Rust's async ecosystem.*

## Features

- **Task & Node APIs**: Single `Task` trait for simple processing logic, or `Node` trait for structured three-phase lifecycle
- **State Machines**: Type-safe enum-driven state transitions with compile-time checking
- **Retry Strategies**: None, fixed delays, and exponential backoff with jitter (for both Tasks and Nodes)
- **Flexible Storage**: Built-in `MemoryStore` or custom struct types for data sharing
- **Workflow Scheduling** (optional `scheduler` feature): Built-in scheduler with intervals, cron schedules, and manual triggers
- **Concurrent Execution**: Execute multiple workflow instances in parallel with timeout strategies
- **Observability** (optional `tracing` feature): Comprehensive tracing and observability for workflow execution
- **All Features** (optional `all` feature): Convenience feature that enables both `scheduler` and `tracing`
- **Performance**: Minimal overhead with direct execution and zero-cost abstractions

## Getting Started

Add Cano to your `Cargo.toml`:

```toml
[dependencies]
cano = "0.6"
async-trait = "0.1"
tokio = { version = "1", features = ["macros", "sync", "time", "rt-multi-thread"] }
```

For scheduler support:

```toml
[dependencies]
cano = { version = "0.6", features = ["scheduler"] }
```

For observability and tracing:

```toml
[dependencies]
cano = { version = "0.6", features = ["tracing"] }
tracing = "0.1"
```

Or use the `all` feature for convenience:

```toml
[dependencies]
cano = { version = "0.6", features = ["all"] }
tracing = "0.1"
```

### Basic Example

```rust
use async_trait::async_trait;
use cano::prelude::*;

// Define your workflow states
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
enum WorkflowState {
    Start,
    Process,
    Complete,
}

// Simple Task implementation - single run method
struct SimpleTask;

#[async_trait]
impl Task<WorkflowState> for SimpleTask {
    fn config(&self) -> TaskConfig {
        // Configure retry behavior for resilience
        TaskConfig::new().with_exponential_retry(2)
    }

    async fn run(&self, store: &MemoryStore) -> Result<WorkflowState, CanoError> {
        let input: String = store.get("input").unwrap_or_default();
        println!("Processing: {input}");
        store.put("result", "task_processed".to_string())?;
        Ok(WorkflowState::Process)
    }
}

// Structured Node implementation - three-phase lifecycle
struct ProcessorNode;

#[async_trait]
impl Node<WorkflowState> for ProcessorNode {
    type PrepResult = String;
    type ExecResult = bool;

    async fn prep(&self, store: &MemoryStore) -> Result<Self::PrepResult, CanoError> {
        let input: String = store.get("result").unwrap_or_default();
        Ok(input)
    }

    async fn exec(&self, prep_res: Self::PrepResult) -> Self::ExecResult {
        println!("Node processing: {prep_res}");
        true // Success
    }

    async fn post(&self, store: &MemoryStore, exec_res: Self::ExecResult) 
        -> Result<WorkflowState, CanoError> {
        if exec_res {
            store.put("final_result", "node_processed".to_string())?;
            Ok(WorkflowState::Complete)
        } else {
            Ok(WorkflowState::Process) // Retry
        }
    }
}

#[tokio::main]
async fn main() -> Result<(), CanoError> {
    // Create workflow - can mix Tasks and Nodes
    let mut workflow = Workflow::new(WorkflowState::Start);
    workflow.register(WorkflowState::Start, SimpleTask)        // Task
        .register(WorkflowState::Process, ProcessorNode)       // Node
        .add_exit_state(WorkflowState::Complete);
    
    // Create store and run workflow
    let store = MemoryStore::new();
    store.put("input", "Hello Cano!".to_string())?;
    
    let result = workflow.orchestrate(&store).await?;
    println!("Workflow completed: {result:?}");
    
    Ok(())
}
```

## Core Concepts

### 1. Tasks & Nodes - Processing Units

Cano provides two approaches for implementing processing logic:

#### Tasks - Simple & Flexible

A `Task` provides a simplified interface with a single `run` method. Use tasks when you want simplicity and direct control over the execution logic. Both `Task` and `Node` support retry strategies.

```rust
struct DataProcessor;

#[async_trait]
impl Task<String> for DataProcessor {
    fn config(&self) -> TaskConfig {
        // Configure retry behavior (optional)
        TaskConfig::new().with_fixed_retry(3, Duration::from_secs(1))
    }

    async fn run(&self, store: &MemoryStore) -> Result<String, CanoError> {
        // Load data, process, and store results in one place
        Ok("complete".to_string())
    }
}
```

#### Nodes - Structured & Resilient  

A `Node` implements a structured three-phase lifecycle with built-in retry capabilities. Nodes are ideal for complex operations where separating data loading, execution, and result handling improves clarity and maintainability.

1. **Prep**: Load data, validate inputs, setup resources
2. **Exec**: Core processing logic (with automatic retry support)  
3. **Post**: Store results, cleanup, determine next action

```rust
struct EmailProcessor;

#[async_trait]
impl Node<String> for EmailProcessor {
    type PrepResult = String;
    type ExecResult = bool;

    async fn prep(&self, store: &MemoryStore) -> Result<Self::PrepResult, CanoError> {
        let email: String = store.get("email").unwrap_or_default();
        Ok(email)
    }

    async fn exec(&self, email: Self::PrepResult) -> Self::ExecResult {
        println!("Sending email to: {email}");
        true // Success
    }

    async fn post(&self, store: &MemoryStore, success: Self::ExecResult) 
        -> Result<String, CanoError> {
        if success {
            Ok("complete".to_string())
        } else {
            Ok("failed".to_string())
        }
    }
}
```

#### Compatibility & When to Use Which

- **Every Node automatically implements Task** - you can use any Node wherever Tasks are accepted.
- **Use Task for**: Simple processing, quick prototypes, or when you prefer a single method for all logic.
- **Use Node for**: Complex processing that benefits from a structured three-phase lifecycle (prep, exec, post).

#### Retry Strategies

Both Tasks and Nodes support retry strategies. Configure retry behavior using `TaskConfig`:

```rust
// Task with retry configuration
impl Task<WorkflowState> for ReliableTask {
    fn config(&self) -> TaskConfig {
        // Exponential backoff with 5 retries
        TaskConfig::new().with_exponential_retry(5)
    }

    async fn run(&self, store: &MemoryStore) -> Result<WorkflowState, CanoError> {
        // Your task logic here...
        Ok(WorkflowState::Complete)
    }
}

// Node with retry configuration
impl Node<WorkflowState> for ReliableNode {
    fn config(&self) -> TaskConfig {
        // No retries (fail fast)
        TaskConfig::minimal()
    }
    // ... rest of implementation
}
```

### 2. Store - Data Sharing

Cano supports flexible data sharing between workflow nodes through stores.

#### MemoryStore (Key-Value Store)

The built-in MemoryStore provides a flexible key-value interface:

```rust
let store = MemoryStore::new();

// Store different types of data
store.put("user_id", 123)?;
store.put("name", "Alice".to_string())?;
store.put("scores", vec![85, 92, 78])?;

// Retrieve data with type safety
let user_id: i32 = store.get("user_id")?;
let name: String = store.get("name")?;

// Append items to existing collections
store.append("scores", 95)?;  // scores is now [85, 92, 78, 95]

// Store operations
let count = store.len()?;
let is_empty = store.is_empty()?;
store.clear()?;
```

#### Custom Store Types

For better performance and type safety, use custom struct types:

```rust
#[derive(Debug, Clone, Default)]
struct RequestCtx {
    pub request_id: String,
    pub transaction_count: i32,
}

#[async_trait]
impl Node<ProcessingState, RequestCtx> for MetricsNode {
    async fn prep(&self, store: &RequestCtx) -> Result<String, CanoError> {
        // Direct field access - no hash map overhead
        Ok(store.request_id.clone())
    }

    async fn post(&self, store: &RequestCtx, result: ProcessingResult) 
        -> Result<ProcessingState, CanoError> {
        println!("Processing request: {}", store.request_id);
        Ok(ProcessingState::Complete)
    }
}
```

### 3. Workflows - State Management

Build workflows with state machine semantics. Workflows can register both Tasks and Nodes using the unified `register` method:

```rust
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
enum WorkflowState {
    Validate,
    Process,
    Complete,
    Error,
}

let mut workflow = Workflow::new(WorkflowState::Validate);
workflow.register(WorkflowState::Validate, validator_task)  // Task
    .register(WorkflowState::Process, processor_node)       // Node  
    .add_exit_states(vec![WorkflowState::Complete, WorkflowState::Error]);

let result = workflow.orchestrate(&store).await?;
```

#### Complex Workflows

Build sophisticated state machine pipelines with conditional branching and error handling:

```mermaid
graph TD
    A[Start] --> B[LoadData]
    B --> C{Validate}
    C -->|Valid| D[Process]
    C -->|Invalid| E[Sanitize]  
    C -->|Critical Error| F[Error]
    E --> D
    D --> G{QualityCheck}
    G -->|High Quality| H[Enrich]
    G -->|Low Quality| I[BasicProcess]
    G -->|Failed & Retries Left| J[Retry]
    G -->|Failed & No Retries| K[Failed]
    H --> L[Complete]
    I --> L
    J --> D
    F --> M[Cleanup]
    M --> K
```

```rust
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
enum OrderState {
    Start,
    LoadData,
    Validate,
    Sanitize,
    Process,
    QualityCheck,
    Enrich,
    BasicProcess,
    Retry,
    Cleanup,
    Complete,
    Failed,
    Error,
}

// Validation node with multiple outcomes
struct ValidationNode;

#[async_trait]
impl Node<OrderState> for ValidationNode {
    type PrepResult = String;
    type ExecResult = ValidationResult;

    async fn prep(&self, store: &MemoryStore) -> Result<Self::PrepResult, CanoError> {
        let data: String = store.get("raw_data")?;
        Ok(data)
    }

    async fn exec(&self, data: Self::PrepResult) -> Self::ExecResult {
        if data.contains("critical_error") {
            ValidationResult::CriticalError
        } else if data.len() < 10 {
            ValidationResult::Invalid
        } else {
            ValidationResult::Valid
        }
    }

    async fn post(&self, store: &MemoryStore, result: Self::ExecResult) 
        -> Result<OrderState, CanoError> {
        match result {
            ValidationResult::Valid => Ok(OrderState::Process),
            ValidationResult::Invalid => Ok(OrderState::Sanitize),
            ValidationResult::CriticalError => Ok(OrderState::Error),
        }
    }
}

// Quality check node with retry logic
struct QualityCheckNode;

#[async_trait]
impl Node<OrderState> for QualityCheckNode {
    type PrepResult = (String, i32);
    type ExecResult = QualityScore;

    async fn prep(&self, store: &MemoryStore) -> Result<Self::PrepResult, CanoError> {
        let data: String = store.get("processed_data")?;
        let attempt: i32 = store.get("retry_count").unwrap_or(0);
        Ok((data, attempt))
    }

    async fn exec(&self, (data, attempt): Self::PrepResult) -> Self::ExecResult {
        let score = calculate_quality_score(&data);
        QualityScore { score, attempt }
    }

    async fn post(&self, store: &MemoryStore, result: Self::ExecResult) 
        -> Result<OrderState, CanoError> {
        store.put("quality_score", result.score)?;
        
        match result.score {
            90..=100 => Ok(OrderState::Enrich),
            60..=89 => Ok(OrderState::BasicProcess),
            _ if result.attempt < 3 => {
                store.put("retry_count", result.attempt + 1)?;
                Ok(OrderState::Retry)
            }
            _ => Ok(OrderState::Failed),
        }
    }
}

// OTHER NODES ...

// Build the complete workflow
let mut workflow = Workflow::new(OrderState::Start);
workflow
    .register(OrderState::Start, DataLoaderNode)
    .register(OrderState::Validate, ValidationNode)
    .register(OrderState::Sanitize, SanitizeNode)  
    .register(OrderState::Process, ProcessNode)
    .register(OrderState::QualityCheck, QualityCheckNode)
    .register(OrderState::Enrich, EnrichNode)
    .register(OrderState::BasicProcess, CompleteNode)
    .register(OrderState::Retry, ProcessNode)
    .register(OrderState::Error, CleanupNode)
    .add_exit_states(vec![OrderState::Complete, OrderState::Failed]);

let result = workflow.orchestrate(&store).await?;
```

### Concurrent Workflows

Execute multiple workflow instances in parallel with different timeout strategies:

```rust
use cano::prelude::*;

// Create a concurrent workflow with the same API as regular workflows
let mut concurrent_workflow = ConcurrentWorkflow::new(ProcessingState::Start);
concurrent_workflow.register(ProcessingState::Start, processing_node);
concurrent_workflow.add_exit_state(ProcessingState::Complete);

// Execute with different wait strategies
let stores: Vec<MemoryStore> = (0..10).map(|_| MemoryStore::new()).collect();

// Wait for all workflows to complete
let (results, status) = concurrent_workflow
    .execute_concurrent(stores.clone(), WaitStrategy::WaitForever)
    .await?;

// Wait for first 5 to complete, then cancel the rest
let (results, status) = concurrent_workflow
    .execute_concurrent(stores.clone(), WaitStrategy::WaitForQuota(5))
    .await?;

// Execute within time limit
let (results, status) = concurrent_workflow
    .execute_concurrent(stores, WaitStrategy::WaitDuration(Duration::from_secs(30)))
    .await?;
```
## Scheduling Workflows

The Scheduler provides workflow scheduling capabilities for background jobs and automated workflows:

```rust
use cano::prelude::*;
use tokio::time::Duration;

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
enum MyState {
    Start,
    Complete,
}

#[derive(Clone)]
struct MyTask;

#[async_trait::async_trait]
impl Node<MyState> for MyTask {
    type PrepResult = ();
    type ExecResult = bool;

    async fn prep(&self, _store: &MemoryStore) -> Result<Self::PrepResult, CanoError> {
        Ok(())
    }

    async fn exec(&self, _prep_res: Self::PrepResult) -> Self::ExecResult {
        println!("Executing task...");
        true
    }

    async fn post(&self, _store: &MemoryStore, exec_res: Self::ExecResult) 
        -> Result<MyState, CanoError> {
        if exec_res {
            Ok(MyState::Complete)
        } else {
            Ok(MyState::Start)
        }
    }
}

#[tokio::main]
async fn main() -> CanoResult<()> {
    let mut scheduler = Scheduler::new();
    
    // Create regular workflows with consistent API
    let mut workflow1 = Workflow::new(MyState::Start);
    workflow1.register(MyState::Start, MyTask);
    workflow1.add_exit_state(MyState::Complete);

    let mut workflow2 = Workflow::new(MyState::Start);
    workflow2.register(MyState::Start, MyTask);
    workflow2.add_exit_state(MyState::Complete);
    
    // Schedule regular workflows
    scheduler.every_seconds("task1", workflow1.clone(), 30)?;          // Every 30 seconds
    scheduler.every_minutes("task2", workflow2.clone(), 5)?;           // Every 5 minutes  
    scheduler.cron("task3", workflow1.clone(), "0 0 9 * * *")?;        // Daily at 9 AM
    scheduler.manual("task4", workflow1)?;                             // Manual trigger only
    
    // Create concurrent workflow with identical API to regular workflows
    let mut concurrent_workflow = ConcurrentWorkflow::new(MyState::Start);
    concurrent_workflow.register(MyState::Start, MyTask);
    concurrent_workflow.add_exit_state(MyState::Complete);
    
    // Schedule concurrent workflows (multiple instances in parallel)
    scheduler.manual_concurrent("concurrent1", concurrent_workflow.clone(), 
        3, WaitStrategy::WaitForever)?;                                // 3 instances, wait for all
    scheduler.every_seconds_concurrent("concurrent2", concurrent_workflow, 
        60, 5, WaitStrategy::WaitForQuota(3))?;                        // 5 instances every minute, wait for 3
    
    // Start the scheduler
    scheduler.start().await?;
    
    // Trigger workflows
    scheduler.trigger("task4").await?;
    
    // Monitor status
    if let Some(status) = scheduler.status("task1").await {
        println!("Task1 status: {:?}", status);
    }
    
    // Graceful shutdown
    scheduler.stop().await?;
    
    Ok(())
}
```

### Features

- **Flexible Scheduling**: Intervals, cron expressions, and manual triggers
- **Concurrent Workflows**: Execute multiple workflow instances in parallel with configurable wait strategies
- **Status Monitoring**: Check workflow status, run counts, and execution times
- **Graceful Shutdown**: Stop with timeout for running flows to complete
- **Concurrent Execution**: Multiple flows can run simultaneously

## Workflow Observability & Tracing

Cano provides comprehensive observability through the optional `tracing` feature using the [tracing](https://docs.rs/tracing/latest/tracing/) library.

### Enable Tracing

```toml
[dependencies]
cano = { version = "0.6", features = ["tracing"] }
tracing = "0.1"
tracing-subscriber = "0.3"
```

### What Gets Traced

- **Workflow Level**: Orchestration start/completion, state transitions, final states
- **Task Level**: Task execution with retry logic, attempts, delays, success/failure outcomes
- **Node Level**: Three-phase lifecycle (prep, exec, post), retry attempts with detailed context
- **Scheduler Level**: Workflow scheduling, concurrent execution, run counts, durations
- **Concurrent Workflows**: Individual instance tracking and aggregate statistics

### Basic Usage

```rust
use cano::prelude::*;
use tracing::{info_span, info};
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};

#[tokio::main]
async fn main() -> Result<(), CanoError> {
    // Set up tracing subscriber
    tracing_subscriber::registry()
        .with(tracing_subscriber::EnvFilter::from_default_env())
        .with(tracing_subscriber::fmt::layer())
        .init();

    // Create workflow with custom tracing span
    let workflow_span = info_span!(
        "user_data_processing", 
        user_id = "12345", 
        batch_id = "batch_001"
    );
    
    let mut workflow = Workflow::new(MyState::Start)
        .with_tracing_span(workflow_span);
    
    workflow.register(MyState::Start, MyProcessingNode);
    
    // All execution will be traced under your custom span
    let result = workflow.orchestrate(&store).await?;
    
    Ok(())
}
```

### Advanced Tracing

```rust
// Custom spans for concurrent workflows
let concurrent_span = info_span!("batch_processing", batch_size = 5);
let mut concurrent_workflow = ConcurrentWorkflow::new(MyState::Start)
    .with_tracing_span(concurrent_span);

// Custom tracing in nodes
#[async_trait]
impl Node<MyState> for TracedNode {
    async fn prep(&self, store: &MemoryStore) -> Result<String, CanoError> {
        info!(node_id = %self.id, "Starting data preparation");
        // Your prep logic - automatically traced
        Ok("prepared".to_string())
    }
    
    async fn exec(&self, prep_result: String) -> bool {
        info!("Processing data: {}", prep_result);
        true
    }
    
    async fn post(&self, store: &MemoryStore, success: bool) -> Result<MyState, CanoError> {
        info!(success, "Node execution completed");
        Ok(MyState::Complete)
    }
}
```

### Tracing Output

With `RUST_LOG=info cargo run`, you'll see structured output like:

```
INFO user_data_processing{user_id="12345" batch_id="batch_001"}: Starting workflow orchestration
  INFO user_data_processing{user_id="12345" batch_id="batch_001"}:task_execution{state=Start}:run_with_retries{max_attempts=4}: Starting task execution with retry logic
    INFO user_data_processing{user_id="12345" batch_id="batch_001"}:task_execution{state=Start}:run_with_retries{max_attempts=4}:task_attempt{attempt=1}: Starting data preparation node_id=processor_1
    INFO user_data_processing{user_id="12345" batch_id="batch_001"}:task_execution{state=Start}:run_with_retries{max_attempts=4}:task_attempt{attempt=1}: Node execution completed success=true
  INFO user_data_processing{user_id="12345" batch_id="batch_001"}:task_execution{state=Start}:run_with_retries{max_attempts=4}: Task execution successful attempt=1
INFO user_data_processing{user_id="12345" batch_id="batch_001"}: Workflow completed successfully final_state=Complete
```

### Performance

- **Zero-cost when disabled**: No overhead when tracing feature is not enabled
- **Minimal impact when enabled**: Structured logging with efficient processing
- **Conditional compilation**: Tracing code only compiled when feature is enabled

Run the tracing demo:

```bash
RUST_LOG=info cargo run --example tracing_demo --features tracing,scheduler
```

## Examples and Testing

### Run Examples

```bash
# Examples directory contains various workflow implementations
cargo run --example [example_name]
```

### Run Tests and Benchmarks

```bash
# Run all tests
cargo test

# Run benchmarks from the benches directory
cargo bench --bench [benchmark_name]
```

Benchmark results are saved in `target/criterion/`.

## Documentation

- **[API Documentation]https://docs.rs/cano** - Complete API reference
- **[Examples Directory]./examples/** - Hands-on code examples
- **[Benchmarks]./benches/** - Performance testing and optimization

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.