WorkDispatcher
A simple yet powerful concurrent data processing dispatcher framework for Rust, built on the Actor model.
WorkDispatcher provides a generic and ergonomic way to set up a system that reads items from a source (Producer) and
dispatches them to a pool of async workers (Processor) for concurrent processing. It abstracts away the complexities
of channels, task spawning, and graceful shutdown, allowing you to focus on your business logic.
Features
- Producer-Consumer Model: Decouples data generation from data processing.
- Concurrent Processing: Leverages a pool of async actors to process items in parallel, maximizing throughput.
- Backpressure Handling: Uses a bounded channel to prevent out-of-memory errors when the producer is faster than the consumers.
- Type-Safe & Generic: Define your own data items, producers, and processors using traits.
- Simple API: Set up and run a complex processing system with a fluent builder-style API.
- Built on Tokio & Flume: Relies on industry-standard crates for high-performance async runtime and channels.
Quick Start
Add work_dispatcher to your Cargo.toml:
[]
= "0.1.0"
= { = "1", = ["full"] }
= "1.0"
= "0.1"
= "0.11"
Then, create your dispatcher in just a few steps:
use Result;
use async_trait;
use Sender;
use Duration;
use ;
// 1. Define your data structure
// 2. Implement the Producer trait for your data source
;
// 3. Implement the Processor trait for your processing logic
;
// 4. Build and run the WorkDispatcher
async
License
This project is licensed: MIT license
Contribution
Contributions are welcome! Please feel free to submit a pull request or open an issue.