Added non-panic error handling for the sink

This commit is contained in:
Emile 2021-07-11 00:32:44 +01:00
parent 1f3ec2bf39
commit 81746dd5dc
1 changed files with 12 additions and 5 deletions

View File

@ -130,11 +130,18 @@ async fn main() -> Result<(), Box<dyn Error>> {
.map_err(|e| Box::new(e) as Box<dyn Error>); .map_err(|e| Box::new(e) as Box<dyn Error>);
tokio::spawn(async move { tokio::spawn(async move {
sender loop {
.sink_map_err(|e| Box::new(e) as Box<dyn Error>) if let Err(err) = sender
.send_all(&mut model) .clone() // Does this even make sense??? Can you clone a sender?? am i fucked now??
.await // shouldnt it be re-init'd?
.expect("Broken buffer"); .sink_map_err(|e| Box::new(e) as Box<dyn Error>)
.send_all(&mut model)
.await
{
// Idk what to do here, remake stream? what? idk, im not rustie
println!("got error on sender stream: {}", err);
}
}
}); });
publisher publisher