Skip to content

Commit

Permalink
simplify the error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mycognosist committed Feb 6, 2024
1 parent 90d4fb6 commit 65e4da2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions solar/src/actors/replication/ebt/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@ type ErrorMsg = String;
pub enum EbtEvent {
WaitForSessionRequest(ConnectionData),
RequestSession(ConnectionData),
// TODO: See if we can remove `ReqNo` from all these events.
// Then `ReqNo` lives purely inside the MUXRPC EBT handler.
SessionInitiated(ConnectionId, ReqNo, SsbId, SessionRole),
SendClock(ConnectionId, ReqNo, VectorClock, SessionRole),
SendMessage(ConnectionId, ReqNo, SsbId, Value, SessionRole),
ReceivedClock(ConnectionId, ReqNo, SsbId, VectorClock),
ReceivedMessage(Message),
SessionConcluded(ConnectionId, SsbId),
SessionTimeout(ConnectionData, SsbId),
Error(ConnectionData, Option<ReqNo>, SsbId, ErrorMsg),
Error(ConnectionData, SsbId, ErrorMsg),
}

/// Role of a peer in an EBT session.
Expand Down Expand Up @@ -694,11 +696,10 @@ impl EbtManager {
async fn handle_error(
&mut self,
connection_data: ConnectionData,
req_no: Option<ReqNo>,
peer_ssb_id: SsbId,
error_msg: ErrorMsg,
) -> Result<()> {
trace!(target: "ebt-replication", "Session error with {} for request number {:?}: {}", peer_ssb_id, req_no, error_msg);
trace!(target: "ebt-replication", "Session error with {}: {}", peer_ssb_id, error_msg);

self.remove_session(connection_data.id);

Expand Down Expand Up @@ -807,8 +808,8 @@ impl EbtManager {
error!("Error while handling 'session timeout' event: {}", err)
}
}
EbtEvent::Error(connection_data, req_no, peer_ssb_id, error_msg) => {
if let Err(err) = self.handle_error(connection_data, req_no, peer_ssb_id, error_msg).await {
EbtEvent::Error(connection_data, peer_ssb_id, error_msg) => {
if let Err(err) = self.handle_error(connection_data, peer_ssb_id, error_msg).await {
error!("Error while handling 'error' event: {}", err)
}
}
Expand Down

0 comments on commit 65e4da2

Please sign in to comment.