From ff3a6f01bcd68484fb04ca1d600fd5af47070fe5 Mon Sep 17 00:00:00 2001 From: Andy Fiddaman Date: Thu, 29 Feb 2024 20:02:30 +0000 Subject: [PATCH] Move strings to constants --- oximeter/db/src/client.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/oximeter/db/src/client.rs b/oximeter/db/src/client.rs index 3906c73e1c..e5b2979f07 100644 --- a/oximeter/db/src/client.rs +++ b/oximeter/db/src/client.rs @@ -50,6 +50,10 @@ use tokio::fs; use tokio::sync::Mutex; use uuid::Uuid; +const CLICKHOUSE_DB_MISSING: &'static str = "Database oximeter does not exist"; +const CLICKHOUSE_DB_VERSION_MISSING: &'static str = + "Table oximeter.version does not exist"; + #[usdt::provider(provider = "clickhouse_client")] mod probes { fn query__start(_: &usdt::UniqueId, sql: &str) {} @@ -856,12 +860,10 @@ impl Client { })?, Err(Error::Database(err)) // Case 1: The database has not been created. - if err.contains("Database oximeter doesn't exist") || - err.contains("Database oximeter does not exist") || + if err.contains(CLICKHOUSE_DB_MISSING) || // Case 2: The database has been created, but it's old (exists // prior to the version table). - err.contains("Table oximeter.version doesn't exist") || - err.contains("Table oximeter.version does not exist") => + err.contains(CLICKHOUSE_DB_VERSION_MISSING) => { warn!(self.log, "oximeter database does not exist, or is out-of-date"); 0