Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[ISSUE #1798]🤡Optimize DefaultPullCallback#on_exception method code🚀 #1799

Merged
merged 1 commit into from
Dec 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions rocketmq-client/src/consumer/pull_callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,9 @@
}

fn on_exception(&mut self, err: Box<dyn std::error::Error + Send>) {
let mut push_consumer_impl = self.push_consumer_impl.clone();

let message_queue_inner = self.message_queue_inner.take().unwrap();
let pull_request = self.pull_request.take().unwrap();
let topic = message_queue_inner.get_topic().to_string();
let topic = message_queue_inner.get_topic();

Check warning on line 168 in rocketmq-client/src/consumer/pull_callback.rs

View check run for this annotation

Codecov / codecov/patch

rocketmq-client/src/consumer/pull_callback.rs#L168

Added line #L168 was not covered by tests
if !topic.starts_with(mix_all::RETRY_GROUP_TOPIC_PREFIX) {
if let Some(er) = err.downcast_ref::<MQClientError>() {
match er {
Expand All @@ -177,26 +175,26 @@
{
warn!(
"the subscription is not latest, group={}",
push_consumer_impl.consumer_config.consumer_group,
self.push_consumer_impl.consumer_config.consumer_group,

Check warning on line 178 in rocketmq-client/src/consumer/pull_callback.rs

View check run for this annotation

Codecov / codecov/patch

rocketmq-client/src/consumer/pull_callback.rs#L178

Added line #L178 was not covered by tests
);
} else {
warn!(
"execute the pull request exception, group={}",
push_consumer_impl.consumer_config.consumer_group
self.push_consumer_impl.consumer_config.consumer_group

Check warning on line 183 in rocketmq-client/src/consumer/pull_callback.rs

View check run for this annotation

Codecov / codecov/patch

rocketmq-client/src/consumer/pull_callback.rs#L183

Added line #L183 was not covered by tests
);
}
}
_ => {
warn!(
"execute the pull request exception, group={}",
push_consumer_impl.consumer_config.consumer_group
self.push_consumer_impl.consumer_config.consumer_group

Check warning on line 190 in rocketmq-client/src/consumer/pull_callback.rs

View check run for this annotation

Codecov / codecov/patch

rocketmq-client/src/consumer/pull_callback.rs#L190

Added line #L190 was not covered by tests
);
}
}
} else {
warn!(
"execute the pull request exception, group={}",
push_consumer_impl.consumer_config.consumer_group
self.push_consumer_impl.consumer_config.consumer_group

Check warning on line 197 in rocketmq-client/src/consumer/pull_callback.rs

View check run for this annotation

Codecov / codecov/patch

rocketmq-client/src/consumer/pull_callback.rs#L197

Added line #L197 was not covered by tests
);
}
}
Expand All @@ -207,15 +205,16 @@
{
PULL_TIME_DELAY_MILLS_WHEN_BROKER_FLOW_CONTROL
} else {
push_consumer_impl.pull_time_delay_mills_when_exception
self.push_consumer_impl.pull_time_delay_mills_when_exception

Check warning on line 208 in rocketmq-client/src/consumer/pull_callback.rs

View check run for this annotation

Codecov / codecov/patch

rocketmq-client/src/consumer/pull_callback.rs#L208

Added line #L208 was not covered by tests
}
}
_ => push_consumer_impl.pull_time_delay_mills_when_exception,
_ => self.push_consumer_impl.pull_time_delay_mills_when_exception,

Check warning on line 211 in rocketmq-client/src/consumer/pull_callback.rs

View check run for this annotation

Codecov / codecov/patch

rocketmq-client/src/consumer/pull_callback.rs#L211

Added line #L211 was not covered by tests
}
} else {
push_consumer_impl.pull_time_delay_mills_when_exception
self.push_consumer_impl.pull_time_delay_mills_when_exception

Check warning on line 214 in rocketmq-client/src/consumer/pull_callback.rs

View check run for this annotation

Codecov / codecov/patch

rocketmq-client/src/consumer/pull_callback.rs#L214

Added line #L214 was not covered by tests
};

push_consumer_impl.execute_pull_request_later(pull_request, time_delay);
self.push_consumer_impl
.execute_pull_request_later(pull_request, time_delay);

Check warning on line 218 in rocketmq-client/src/consumer/pull_callback.rs

View check run for this annotation

Codecov / codecov/patch

rocketmq-client/src/consumer/pull_callback.rs#L217-L218

Added lines #L217 - L218 were not covered by tests
}
}
Loading