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
//! Bounded, typed, process-local connection between subscriptions.
//!
//! Always available; no Cargo feature is required.
//!
//! [`channel`] connects the sink of one subscription to the source of the next, so a
//! pipeline can split I/O-bound and CPU-bound stages into subscriptions with their
//! own concurrency, retries, and error policies, for example an async handler that
//! fetches data followed by a [`blocking`](crate::blocking) handler that scores it.
//!
//! ```
//! use beavers::{App, InMemorySink, IterSource, Result, blocking, channel};
//!
//! async fn fetch(id: u32) -> Result<String> {
//! Ok(format!("document {id}"))
//! }
//!
//! fn score(document: String) -> Result<usize> {
//! Ok(document.len())
//! }
//!
//! # #[tokio::main] async fn main() -> std::result::Result<(), beavers::Error> {
//! let (to_score, fetched) = channel(16);
//! let scores = InMemorySink::default();
//! App::new()
//! .subscribe("fetch", IterSource::new([1, 2]), to_score, fetch)
//! .subscribe("score", fetched, scores.clone(), blocking(score))
//! .run()
//! .await?;
//! assert_eq!(scores.values(), [10, 10]);
//! # Ok(()) }
//! ```
pub use channel;
pub use ;
pub use ;
pub use ;