mirror of
https://github.com/postgresml/pgcat.git
synced 2026-03-23 01:16:30 +00:00
Fix lint warnings for rust-1.79 (#769)
2 things that are recommended by rust-lang - implementing `std::fmt::Display` rather than ToString (1) and using clone_from (2). [1] https://rust-lang.github.io/rust-clippy/master/index.html#/to_string_trait_impl [2] https://rust-lang.github.io/rust-clippy/master/index.html#assigning_clones Signed-off-by: Brandon Pike <pikebrandon@att.net>
This commit is contained in:
@@ -38,12 +38,12 @@ pub enum Role {
|
|||||||
Mirror,
|
Mirror,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToString for Role {
|
impl std::fmt::Display for Role {
|
||||||
fn to_string(&self) -> String {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match *self {
|
match self {
|
||||||
Role::Primary => "primary".to_string(),
|
Role::Primary => write!(f, "primary"),
|
||||||
Role::Replica => "replica".to_string(),
|
Role::Replica => write!(f, "replica"),
|
||||||
Role::Mirror => "mirror".to_string(),
|
Role::Mirror => write!(f, "mirror"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -476,11 +476,11 @@ pub enum PoolMode {
|
|||||||
Session,
|
Session,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToString for PoolMode {
|
impl std::fmt::Display for PoolMode {
|
||||||
fn to_string(&self) -> String {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match *self {
|
match self {
|
||||||
PoolMode::Transaction => "transaction".to_string(),
|
PoolMode::Transaction => write!(f, "transaction"),
|
||||||
PoolMode::Session => "session".to_string(),
|
PoolMode::Session => write!(f, "session"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -493,12 +493,13 @@ pub enum LoadBalancingMode {
|
|||||||
#[serde(alias = "loc", alias = "LOC", alias = "least_outstanding_connections")]
|
#[serde(alias = "loc", alias = "LOC", alias = "least_outstanding_connections")]
|
||||||
LeastOutstandingConnections,
|
LeastOutstandingConnections,
|
||||||
}
|
}
|
||||||
impl ToString for LoadBalancingMode {
|
|
||||||
fn to_string(&self) -> String {
|
impl std::fmt::Display for LoadBalancingMode {
|
||||||
match *self {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
LoadBalancingMode::Random => "random".to_string(),
|
match self {
|
||||||
|
LoadBalancingMode::Random => write!(f, "random"),
|
||||||
LoadBalancingMode::LeastOutstandingConnections => {
|
LoadBalancingMode::LeastOutstandingConnections => {
|
||||||
"least_outstanding_connections".to_string()
|
write!(f, "least_outstanding_connections")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -999,15 +1000,17 @@ impl Config {
|
|||||||
pub fn fill_up_auth_query_config(&mut self) {
|
pub fn fill_up_auth_query_config(&mut self) {
|
||||||
for (_name, pool) in self.pools.iter_mut() {
|
for (_name, pool) in self.pools.iter_mut() {
|
||||||
if pool.auth_query.is_none() {
|
if pool.auth_query.is_none() {
|
||||||
pool.auth_query = self.general.auth_query.clone();
|
pool.auth_query.clone_from(&self.general.auth_query);
|
||||||
}
|
}
|
||||||
|
|
||||||
if pool.auth_query_user.is_none() {
|
if pool.auth_query_user.is_none() {
|
||||||
pool.auth_query_user = self.general.auth_query_user.clone();
|
pool.auth_query_user
|
||||||
|
.clone_from(&self.general.auth_query_user);
|
||||||
}
|
}
|
||||||
|
|
||||||
if pool.auth_query_password.is_none() {
|
if pool.auth_query_password.is_none() {
|
||||||
pool.auth_query_password = self.general.auth_query_password.clone();
|
pool.auth_query_password
|
||||||
|
.clone_from(&self.general.auth_query_password);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1155,7 +1158,7 @@ impl Config {
|
|||||||
"Default max server lifetime: {}ms",
|
"Default max server lifetime: {}ms",
|
||||||
self.general.server_lifetime
|
self.general.server_lifetime
|
||||||
);
|
);
|
||||||
info!("Sever round robin: {}", self.general.server_round_robin);
|
info!("Server round robin: {}", self.general.server_round_robin);
|
||||||
match self.general.tls_certificate.clone() {
|
match self.general.tls_certificate.clone() {
|
||||||
Some(tls_certificate) => {
|
Some(tls_certificate) => {
|
||||||
info!("TLS certificate: {}", tls_certificate);
|
info!("TLS certificate: {}", tls_certificate);
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ pub enum ShardingFunction {
|
|||||||
Sha1,
|
Sha1,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToString for ShardingFunction {
|
impl std::fmt::Display for ShardingFunction {
|
||||||
fn to_string(&self) -> String {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match *self {
|
match self {
|
||||||
ShardingFunction::PgBigintHash => "pg_bigint_hash".to_string(),
|
ShardingFunction::PgBigintHash => write!(f, "pg_bigint_hash"),
|
||||||
ShardingFunction::Sha1 => "sha1".to_string(),
|
ShardingFunction::Sha1 => write!(f, "sha1"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user