Module reactive_mutiny::uni

source ·
Expand description

Allows creating unis, which represent pairs of (producer, event pipeline) that may be used to produce() asynchronous payloads to be processed by a single event pipeline Stream – and executed by one or more async tasks.

Usage:

   fn on_event(stream: impl Stream<Item=String>) -> impl Stream<Item=String> {
       stream
           .inspect(|message| println!("To Zeta: '{}'", message))
           .inspect(|sneak_peeked_message| println!("EARTH: Sneak peeked a message to Zeta Reticuli: '{}'", sneak_peeked_message))
           .inspect(|message| println!("ZETA: Received a message: '{}'", message))
   }
   let uni = UniBuilder::new()
       .on_stream_close(|_| async {})
       .spawn_non_futures_non_fallible_executor("doc_test() Event", on_event);
   let producer = uni.producer_closure();
   producer("I've just arrived!".to_string()).await;
   producer("Nothing really interesting here... heading back home!".to_string()).await;
   uni.close().await;

Modules

  • Provides channels to be used in Unis

Macros

  • Macro to close, atomically, all Unis passed as parameters TODO the closer may receive a time limit to wait – returning how many elements were still there after if gave up waiting TODO busy wait ahead – is it possible to get rid of that without having to poll & sleep? (anyway, this function is not meant to be used in production – unless when quitting the app… so this is not a priority)

Structs

  • Contains the producer-side Uni handle used to interact with the uni event – for closing the stream, requiring stats, …