chore: make clippy lint happy (#225)

* chore: make clippy happy

* chore: cargo fmt

* chore: cargo fmt
This commit is contained in:
Cluas
2022-11-10 02:04:31 +08:00
committed by GitHub
parent 4bd5717ab1
commit dfa26ec6f8
13 changed files with 167 additions and 207 deletions

View File

@@ -377,7 +377,7 @@ where
let admin = ["pgcat", "pgbouncer"]
.iter()
.filter(|db| *db == &pool_name)
.filter(|db| *db == pool_name)
.count()
== 1;
@@ -389,7 +389,7 @@ where
);
error_response_terminal(
&mut write,
&format!("terminating connection due to administrator command"),
"terminating connection due to administrator command",
)
.await?;
return Err(Error::ShuttingDown);
@@ -446,7 +446,7 @@ where
}
// Authenticate normal user.
else {
let pool = match get_pool(&pool_name, &username) {
let pool = match get_pool(pool_name, username) {
Some(pool) => pool,
None => {
error_response(
@@ -464,7 +464,7 @@ where
};
// Compare server and client hashes.
let password_hash = md5_hash_password(&username, &pool.settings.user.password, &salt);
let password_hash = md5_hash_password(username, &pool.settings.user.password, &salt);
if password_hash != password_response {
warn!("Invalid password {{ username: {:?}, pool_name: {:?}, application_name: {:?} }}", pool_name, username, application_name);
@@ -487,9 +487,9 @@ where
trace!("Startup OK");
return Ok(Client {
Ok(Client {
read: BufReader::new(read),
write: write,
write,
addr,
buffer: BytesMut::with_capacity(8196),
cancel_mode: false,
@@ -498,8 +498,8 @@ where
secret_key,
client_server_map,
parameters: parameters.clone(),
stats: stats,
admin: admin,
stats,
admin,
last_address_id: None,
last_server_id: None,
pool_name: pool_name.clone(),
@@ -507,7 +507,7 @@ where
application_name: application_name.to_string(),
shutdown,
connected_to_server: false,
});
})
}
/// Handle cancel request.
@@ -521,9 +521,9 @@ where
) -> Result<Client<S, T>, Error> {
let process_id = bytes.get_i32();
let secret_key = bytes.get_i32();
return Ok(Client {
Ok(Client {
read: BufReader::new(read),
write: write,
write,
addr,
buffer: BytesMut::with_capacity(8196),
cancel_mode: true,
@@ -541,7 +541,7 @@ where
application_name: String::from("undefined"),
shutdown,
connected_to_server: false,
});
})
}
/// Handle a connected and authenticated client.
@@ -557,12 +557,9 @@ where
// Drop the mutex as soon as possible.
// We found the server the client is using for its query
// that it wants to cancel.
Some((process_id, secret_key, address, port)) => (
process_id.clone(),
secret_key.clone(),
address.clone(),
*port,
),
Some((process_id, secret_key, address, port)) => {
(*process_id, *secret_key, address.clone(), *port)
}
// The client doesn't know / got the wrong server,
// we're closing the connection for security reasons.
@@ -573,7 +570,7 @@ where
// Opens a new separate connection to the server, sends the backend_id
// and secret_key and then closes it for security reasons. No other interactions
// take place.
return Ok(Server::cancel(&address, port, process_id, secret_key).await?);
return Server::cancel(&address, port, process_id, secret_key).await;
}
// The query router determines where the query is going to go,
@@ -606,7 +603,7 @@ where
if !self.admin {
error_response_terminal(
&mut self.write,
&format!("terminating connection due to administrator command")
"terminating connection due to administrator command"
).await?;
return Ok(())
}
@@ -998,14 +995,14 @@ where
) -> Result<(), Error> {
debug!("Sending {} to server", code);
self.send_server_message(server, message, &address, &pool)
self.send_server_message(server, message, address, pool)
.await?;
let query_start = Instant::now();
// Read all data the server has to offer, which can be multiple messages
// buffered in 8196 bytes chunks.
loop {
let response = self.receive_server_message(server, &address, &pool).await?;
let response = self.receive_server_message(server, address, pool).await?;
match write_all_half(&mut self.write, response).await {
Ok(_) => (),