Open barafael opened 3 months ago
In this example, we just send and receive to a yaque. After receiving, we commit on the RecvGuard.
RecvGuard
Is it intentional that on the next start of the program, the yaque still contains all the previously recvd data?
recv
Running this example twice prints the bytes from the first run during the second run even though they were committed in the first run.
use std::time::Duration; use yaque::recovery::recover; #[tokio::main] async fn main() { recover("persistent-data").ok(); let (mut sender, mut receiver) = yaque::channel("persistent-data").unwrap(); let mut interval = tokio::time::interval(Duration::from_secs(1)); let mut counter = 0u64; loop { tokio::select! { _tick = interval.tick() => { println!("Enqueuing {counter}"); let Ok(_) = sender.send(format!("Message {counter}")).await else { break; }; counter += 1; } guard = receiver.recv() => { println!("Got batch"); let Ok(contents) = guard else { println!("Breaking because guard not OK"); break; }; // println!("{}", String::from_utf8((&mut *contents).drain(..).flatten().collect::<Vec<_>>()).unwrap()); println!("{:?}", String::from_utf8(contents.to_vec())); contents.commit().unwrap(); println!("committed"); } } } }
In this example, we just send and receive to a yaque. After receiving, we commit on the
RecvGuard
.Is it intentional that on the next start of the program, the yaque still contains all the previously
recv
d data?Running this example twice prints the bytes from the first run during the second run even though they were committed in the first run.