Skip to content

Commit

Permalink
Return error when connecting to remote metadata store peer
Browse files Browse the repository at this point in the history
  • Loading branch information
tillrohrmann committed Nov 27, 2024
1 parent d6cf7d1 commit eb5b9ec
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crates/metadata-store/src/network/networking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ use tracing::{debug, trace};
pub enum TrySendError<T> {
#[error("failed sending message")]
Send(T),
#[error("connecting to peer")]
Connecting(T),
#[error("unknown peer: {0}")]
UnknownPeer(u64),
#[error(transparent)]
Expand Down Expand Up @@ -81,7 +83,7 @@ impl Networking {
} else if let Some(address) = self.addresses.get(&target) {
if let Some(task_handle) = self.connection_attempts.remove(&target) {
if !task_handle.is_finished() {
return Ok(());
return Err(TrySendError::Connecting(message));
} else {
match task_handle.now_or_never().expect("should be finished") {
Ok(result) => {
Expand All @@ -107,6 +109,7 @@ impl Networking {
&Configuration::pinned().networking,
)?,
);
return Err(TrySendError::Connecting(message));
} else {
return Err(TrySendError::UnknownPeer(target));
}
Expand Down

0 comments on commit eb5b9ec

Please sign in to comment.