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
//! # rust-pipe
//!
//! Lightweight typed task dispatch from Rust to polyglot workers.
//!
//! rust-pipe lets you dispatch tasks from a Rust orchestrator to workers written in
//! TypeScript, Python, Go, Java, C#, Ruby, Elixir, Swift, PHP, or any CLI tool.
//!
//! ## Quick start
//!
//! ```no_run
//! use rust_pipe::prelude::*;
//! use serde_json::json;
//! use std::time::Duration;
//!
//! #[tokio::main]
//! async fn main() {
//! let dispatcher = Dispatcher::builder()
//! .host("0.0.0.0")
//! .port(9876)
//! .build();
//!
//! dispatcher.start().await.unwrap();
//!
//! let task = Task::new("my-task", json!({"key": "value"}))
//! .with_timeout(30_000)
//! .with_priority(Priority::High);
//!
//! let handle = dispatcher.dispatch(task).await.unwrap();
//! let result = handle.await_with_timeout(Duration::from_secs(30)).await.unwrap();
//! println!("Done: {:?}", result.payload);
//! }
//! ```
/// Common types re-exported for convenience.