Skip to content

Commit

Permalink
[ISSUE #1484]♻️Refactor create MQBrokerErr replace with client_broker…
Browse files Browse the repository at this point in the history
…_err! macro🔥 (#1486)
  • Loading branch information
mxsm authored Dec 1, 2024
1 parent c059ee5 commit 515a349
Showing 1 changed file with 40 additions and 45 deletions.
85 changes: 40 additions & 45 deletions rocketmq-client/src/implementation/mq_client_api_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ use tracing::error;
use tracing::warn;

use crate::base::client_config::ClientConfig;
use crate::client_broker_err;
use crate::client_error::MQBrokerErr;
use crate::client_error::MQClientError;
use crate::client_error::MQClientError::MQClientBrokerError;
Expand Down Expand Up @@ -683,13 +684,11 @@ impl MQClientAPIImpl {
if ResponseCode::from(response.code()) == ResponseCode::Success {
return Ok(response.version());
}
Err(MQClientError::MQClientBrokerError(
MQBrokerErr::new_with_broker(
response.code(),
response.remark().map_or("".to_string(), |s| s.to_string()),
addr.to_string(),
),
))
client_broker_err!(
response.code(),
response.remark().map_or("".to_string(), |s| s.to_string()),
addr.to_string()
)
}

pub async fn check_client_in_broker(
Expand Down Expand Up @@ -777,13 +776,11 @@ impl MQClientAPIImpl {
));
}
}
Err(MQClientError::MQClientBrokerError(
MQBrokerErr::new_with_broker(
response.code(),
response.remark().map_or("".to_string(), |s| s.to_string()),
addr.to_string(),
),
))
client_broker_err!(
response.code(),
response.remark().map_or("".to_string(), |s| s.to_string()),
addr.to_string()
)
}

pub async fn update_consumer_offset_oneway(
Expand Down Expand Up @@ -870,13 +867,11 @@ impl MQClientAPIImpl {
}
_ => {}
}
Err(MQClientError::MQClientBrokerError(
MQBrokerErr::new_with_broker(
response.code(),
response.remark().map_or("".to_string(), |s| s.to_string()),
addr.to_string(),
),
))
client_broker_err!(
response.code(),
response.remark().map_or("".to_string(), |s| s.to_string()),
addr.to_string()
)
}

pub async fn pull_message<PCB>(
Expand Down Expand Up @@ -972,11 +967,11 @@ impl MQClientAPIImpl {
ResponseCode::PullRetryImmediately => PullStatus::NoMatchedMsg,
ResponseCode::PullOffsetMoved => PullStatus::OffsetIllegal,
_ => {
return Err(MQClientBrokerError(MQBrokerErr::new_with_broker(
return client_broker_err!(
response.code(),
response.remark().map_or("".to_string(), |s| s.to_string()),
addr.to_string(),
)))
addr.to_string()
)
}
};
let response_header = response
Expand Down Expand Up @@ -1039,11 +1034,11 @@ impl MQClientAPIImpl {
if ResponseCode::from(response.code()) == ResponseCode::Success {
Ok(())
} else {
Err(MQClientBrokerError(MQBrokerErr::new_with_broker(
client_broker_err!(
response.code(),
response.remark().map_or("".to_string(), |s| s.to_string()),
addr.to_string(),
)))
addr.to_string()
)
}
}

Expand All @@ -1070,11 +1065,11 @@ impl MQClientAPIImpl {
if ResponseCode::from(response.code()) == ResponseCode::Success {
Ok(())
} else {
Err(MQClientBrokerError(MQBrokerErr::new_with_broker(
client_broker_err!(
response.code(),
response.remark().map_or("".to_string(), |s| s.to_string()),
addr.to_string(),
)))
addr.to_string()
)
}
}

Expand Down Expand Up @@ -1110,11 +1105,11 @@ impl MQClientAPIImpl {
if ResponseCode::from(response.code()) == ResponseCode::Success {
Ok(())
} else {
Err(MQClientBrokerError(MQBrokerErr::new_with_broker(
client_broker_err!(
response.code(),
response.remark().map_or("".to_string(), |s| s.to_string()),
addr.to_string(),
)))
addr.to_string()
)
}
}
}
Expand Down Expand Up @@ -1153,18 +1148,18 @@ impl MQClientAPIImpl {
))
})
} else {
Err(MQClientBrokerError(MQBrokerErr::new_with_broker(
client_broker_err!(
response.code(),
"Response body is empty".to_string(),
addr.to_string(),
)))
addr.to_string()
)
}
} else {
Err(MQClientBrokerError(MQBrokerErr::new_with_broker(
client_broker_err!(
response.code(),
response.remark().map_or("".to_string(), |s| s.to_string()),
addr.to_string(),
)))
addr.to_string()
)
}
}

Expand Down Expand Up @@ -1224,11 +1219,11 @@ impl MQClientAPIImpl {
.expect("decode error");
return Ok(response_header.offset);
}
Err(MQClientBrokerError(MQBrokerErr::new_with_broker(
client_broker_err!(
response.code(),
response.remark().map_or("".to_string(), |s| s.to_string()),
addr.to_string(),
)))
addr.to_string()
)
}

pub async fn set_message_request_mode(
Expand Down Expand Up @@ -1310,10 +1305,10 @@ impl MQClientAPIImpl {
return Ok(None);
}

Err(MQClientBrokerError(MQBrokerErr::new_with_broker(
client_broker_err!(
response.code(),
response.remark().map_or("".to_string(), |s| s.to_string()),
addr.to_string(),
)))
addr.to_string()
)
}
}

0 comments on commit 515a349

Please sign in to comment.