Skip to content

Commit

Permalink
apply various suggestions from @hawkw
Browse files Browse the repository at this point in the history
Co-authored-by: Eliza Weisman <[email protected]>
  • Loading branch information
jswrenn and hawkw committed Jul 28, 2022
1 parent 7e740c6 commit d3d5e39
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/cmd/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl Set {
skip(self, db, dst),
fields(
key = self.key.as_str(),
?expire = self.expire.as_ref().map(Duration::as_secs_f64),
expire = ?self.expire.as_ref(),
),
)]
pub(crate) async fn apply(self, db: &Db, dst: &mut Connection) -> crate::Result<()> {
Expand Down
12 changes: 5 additions & 7 deletions src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ impl Connection {
ConnectionState::Open => continue,
ConnectionState::Closed | ConnectionState::Reset => {
if !self.buffer.is_empty() {
warn! {
incomplete =? self.buffer,
"connection closed with incomplete frame"
};
warn!(
incomplete = ?self.buffer,
"connection closed with incomplete frame",
);
}
return Ok(None);
}
Expand All @@ -104,9 +104,7 @@ impl Connection {
Ok(_) => Ok(ConnectionState::Open),
// the connection was closed abruptly by the peer
Err(e) if e.kind() == ConnectionReset => {
warn! {
"connection closed abruptly by peer"
};
warn!("connection closed abruptly by peer");
Ok(ConnectionState::Reset)
}
// reading failed for some other reason
Expand Down
5 changes: 1 addition & 4 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,7 @@ impl Shared {
}

// The key expired, remove it
debug! {
key = &key.as_str(),
"purged_expired_key",
}
debug!(key = &key.as_str(), "purged_expired_key");
state.entries.remove(key);
state.expirations.remove(&(when, id));
}
Expand Down
7 changes: 2 additions & 5 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ impl Handler {
name = "Handler::run",
skip(self),
fields(
?peer_addr = self.connection.peer_addr().unwrap(),
peer_addr = %self.connection.peer_addr().unwrap(),
),
)]
async fn run(&mut self) -> crate::Result<()> {
Expand Down Expand Up @@ -378,10 +378,7 @@ impl Handler {
// };
// `tracing` provides structured logging, so information is
// "logged" as key-value pairs.
warn! {
%cause,
"failed to parse command from frame"
};
warn!(%cause, "failed to parse command from frame");
// ...and (2) respond to the client with the error:
Command::from_error(cause)
}
Expand Down

0 comments on commit d3d5e39

Please sign in to comment.