Skip to content

Commit

Permalink
handle errors from the fair queue and the case when the queue is empty
Browse files Browse the repository at this point in the history
drops `todo!()` from dealer.rs
  • Loading branch information
rgbkrk committed Dec 30, 2024
1 parent 270bdde commit ab55c51
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/dealer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::transport::AcceptStopHandle;
use crate::util::PeerIdentity;
use crate::{
CaptureSocket, Endpoint, MultiPeerBackend, Socket, SocketBackend, SocketEvent, SocketOptions,
SocketRecv, SocketSend, SocketType, ZmqMessage, ZmqResult,
SocketRecv, SocketSend, SocketType, ZmqError, ZmqMessage, ZmqResult,
};

use async_trait::async_trait;
Expand Down Expand Up @@ -66,8 +66,19 @@ impl SocketRecv for DealerSocket {
Some((_peer_id, Ok(Message::Message(message)))) => {
return Ok(message);
}
Some((_peer_id, _)) => todo!(),
None => todo!(),
Some((_peer_id, Ok(_))) => {
// Ignore non-message frames
continue;
}
Some((_peer_id, Err(e))) => {
// Handle potential errors from the fair queue
return Err(e.into());
}
None => {
// The fair queue is empty, which shouldn't happen in normal operation
// We could either wait for more messages or return an error
return Err(ZmqError::NoMessage);
}
};
}
}
Expand Down

0 comments on commit ab55c51

Please sign in to comment.