Skip to content

Commit

Permalink
Refactor bridge upload loop for better error handling in geph5-bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
nullchinchilla committed Sep 5, 2024
1 parent 828e45e commit 6ce74d9
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions binaries/geph5-bridge/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,28 @@ async fn broker_upload_loop(control_listen: SocketAddr, control_cookie: String)
.incr_stat(format!("{bridge_key}.byte_count"), byte_count as _)
.await
.unwrap();
broker_rpc
.insert_bridge(Mac::new(
BridgeDescriptor {
control_listen,
control_cookie: control_cookie.clone(),
pool: pool.clone(),
expiry: SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap()
.as_secs()
+ 120,
},
blake3::hash(auth_token.as_bytes()).as_bytes(),
))
.await
.unwrap()
.unwrap();
let res = async {
broker_rpc
.insert_bridge(Mac::new(
BridgeDescriptor {
control_listen,
control_cookie: control_cookie.clone(),
pool: pool.clone(),
expiry: SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap()
.as_secs()
+ 120,
},
blake3::hash(auth_token.as_bytes()).as_bytes(),
))
.await?
.map_err(|e| anyhow::anyhow!(e))?;
anyhow::Ok(())
};
if let Err(err) = res.await {
tracing::error!(err = %err, "error in upload_loop");
}
smol::Timer::after(Duration::from_secs(10)).await;
}
}

0 comments on commit 6ce74d9

Please sign in to comment.