rust_pipe/lib.rs
1//! # rust-pipe
2//!
3//! Lightweight typed task dispatch from Rust to polyglot workers.
4//!
5//! rust-pipe lets you dispatch tasks from a Rust orchestrator to workers written in
6//! TypeScript, Python, Go, Java, C#, Ruby, Elixir, Swift, PHP, or any CLI tool.
7//!
8//! ## Quick start
9//!
10//! ```no_run
11//! use rust_pipe::prelude::*;
12//! use serde_json::json;
13//! use std::time::Duration;
14//!
15//! #[tokio::main]
16//! async fn main() {
17//! let dispatcher = Dispatcher::builder()
18//! .host("0.0.0.0")
19//! .port(9876)
20//! .build();
21//!
22//! dispatcher.start().await.unwrap();
23//!
24//! let task = Task::new("my-task", json!({"key": "value"}))
25//! .with_timeout(30_000)
26//! .with_priority(Priority::High);
27//!
28//! let handle = dispatcher.dispatch(task).await.unwrap();
29//! let result = handle.await_with_timeout(Duration::from_secs(30)).await.unwrap();
30//! println!("Done: {:?}", result.payload);
31//! }
32//! ```
33
34pub mod dispatch;
35pub mod schema;
36pub mod transport;
37pub mod validation;
38pub mod worker;
39
40/// Common types re-exported for convenience.
41pub mod prelude {
42 pub use crate::dispatch::{DispatchError, DispatchResult, Dispatcher, DispatcherBuilder};
43 pub use crate::schema::{Priority, Task, TaskResult, TaskStatus};
44 pub use crate::transport::TransportConfig;
45 pub use crate::worker::{PoolError, WorkerInfo, WorkerPool, WorkerStatus};
46}