use channel_tracer::{hook_channel, init};
use tokio::sync::mpsc;
use tokio::time;
#[tokio::main]
async fn main() {
init(5);
let size = 20;
let (tx, mut rx) = mpsc::channel(size);
hook_channel(tx.clone(), "example_channel", size);
tokio::spawn(async move {
for i in 0..50 {
tx.send(format!("Message {}", i)).await.unwrap();
time::sleep(time::Duration::from_millis(100)).await; }
});
tokio::spawn(async move {
while let Some(msg) = rx.recv().await {
tracing::debug!("Received: {}", msg);
time::sleep(time::Duration::from_millis(300)).await; }
});
time::sleep(time::Duration::from_secs(20)).await;
}