Expand description
Allows creating multi
s, which represent pairs of (producer
, event pipeline
) that may be used to
produce()
asynchronous payloads to be processed by a multiple event pipeline
Streams – and executed
by async tasks.
Usage:
fn local_on_event(stream: impl Stream<Item=String>) -> impl Stream<Item=Arc<String>> {
stream.inspect(|message| println!("To Zeta: '{}'", message))
}
fn zeta_on_event(stream: impl Stream<Item=String>) -> impl Stream<Item=Arc<String>> {
stream.inspect(|message| println!("ZETA: Received a message: '{}'", message))
}
fn earth_on_event(stream: impl Stream<Item=String>) -> impl Stream<Item=Arc<String>> {
stream.inspect(|sneak_peeked_message| println!("EARTH: Sneak peeked a message to Zeta Reticuli: '{}'", sneak_peeked_message))
}
let multi = MultiBuilder::new()
.on_stream_close(|_| async {})
.into_executable()
.spawn_non_futures_non_fallible_executor("doc_test() local onEvent()", local_on_event).await
.spawn_non_futures_non_fallible_executor("doc_test() zeta onEvent()", zeta_on_event).await
.spawn_non_futures_non_fallible_executor("doc_test() earth onEvent()", earth_on_event).await
.handle();
let producer = multi.producer_closure();
producer("I've just arrived!".to_string()).await;
producer("Nothing really interesting here... heading back home!".to_string()).await;
multi.close().await;
Re-exports§
pub use crate::types::ChannelCommon;
Modules§
- channels
- Provides channels to be used in Unis
Macros§
- multis_
close_ async - Macro to close, atomically-ish, all Multis passed in as parameters
Structs§
- Executor
Info - Keeps track of the
stream_executor
associated to eachstream_id
- Multi
Multi
is an event handler capable of having several “listeners” – all of which receives all events.
With this struct, it is possible to:
Traits§
- Generic
Multi - This trait exists to allow simplifying generic declarations of concrete Multi types.
See also [GenericUni].
Usage: