Skip to content

Commit

Permalink
refactor: move code out of loop
Browse files Browse the repository at this point in the history
  • Loading branch information
WenyXu committed May 27, 2023
1 parent f0a519b commit ec6b562
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/meta-srv/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,19 +183,19 @@ impl HeartbeatHandlerGroup {
) -> Result<HeartbeatResponse> {
let mut acc = HeartbeatAccumulator::default();
let handlers = self.handlers.read().await;
let role = req
.header
.as_ref()
.and_then(|h| Role::from_i32(h.role))
.context(error::InvalidArgumentsSnafu {
err_msg: format!("invalid role: {:?}", req.header),
})?;

for h in handlers.iter() {
if ctx.is_skip_all() {
break;
}

let role = req
.header
.as_ref()
.and_then(|h| Role::from_i32(h.role))
.context(error::InvalidArgumentsSnafu {
err_msg: format!("invalid role: {:?}", req.header),
})?;

if h.is_acceptable(role) {
h.handle(&req, &mut ctx, &mut acc).await?;
}
Expand Down

0 comments on commit ec6b562

Please sign in to comment.