From b2f61aa1cf00a77ce5b28d0456b128a54fd11a6d Mon Sep 17 00:00:00 2001 From: Weny Xu Date: Tue, 25 Jun 2024 15:56:13 +0800 Subject: [PATCH] fix: format error correctly (#4204) * chore: remove TODO comments * fix: format error correctly --- src/common/meta/src/key.rs | 6 +---- src/common/meta/src/key/flow.rs | 27 +++++++------------ src/common/meta/src/key/flow/flow_name.rs | 11 +++----- src/common/meta/src/key/flow/flownode_flow.rs | 3 +-- .../src/heartbeat/handler/close_region.rs | 3 +-- .../src/heartbeat/handler/downgrade_region.rs | 3 +-- .../src/heartbeat/handler/open_region.rs | 3 +-- .../src/heartbeat/handler/upgrade_region.rs | 3 +-- 8 files changed, 19 insertions(+), 40 deletions(-) diff --git a/src/common/meta/src/key.rs b/src/common/meta/src/key.rs index 22179afbad..ddd6f88a9b 100644 --- a/src/common/meta/src/key.rs +++ b/src/common/meta/src/key.rs @@ -83,20 +83,16 @@ pub mod catalog_name; pub mod datanode_table; -/// TODO(weny):removes id. -#[allow(unused)] pub mod flow; pub mod schema_name; pub mod table_info; pub mod table_name; -pub mod view_info; -// TODO(weny): removes it. -#[allow(deprecated)] pub mod table_route; #[cfg(any(test, feature = "testing"))] pub mod test_utils; mod tombstone; pub(crate) mod txn_helper; +pub mod view_info; use std::collections::{BTreeMap, HashMap, HashSet}; use std::fmt::Debug; diff --git a/src/common/meta/src/key/flow.rs b/src/common/meta/src/key/flow.rs index f66d17da33..07334b46b8 100644 --- a/src/common/meta/src/key/flow.rs +++ b/src/common/meta/src/key/flow.rs @@ -29,9 +29,9 @@ use self::flownode_flow::FlownodeFlowKey; use self::table_flow::TableFlowKey; use crate::ensure_values; use crate::error::{self, Result}; -use crate::key::flow::flow_info::{FlowInfoManager, FlowInfoManagerRef}; -use crate::key::flow::flow_name::{FlowNameManager, FlowNameManagerRef}; -use crate::key::flow::flownode_flow::{FlownodeFlowManager, FlownodeFlowManagerRef}; +use crate::key::flow::flow_info::FlowInfoManager; +use crate::key::flow::flow_name::FlowNameManager; +use crate::key::flow::flownode_flow::FlownodeFlowManager; pub use crate::key::flow::table_flow::{TableFlowManager, TableFlowManagerRef}; use crate::key::txn_helper::TxnOpGetResponseSet; use crate::key::{FlowId, MetaKey}; @@ -214,15 +214,15 @@ impl FlowMetadataManager { let source_table_ids = flow_value.source_table_ids(); let mut keys = Vec::with_capacity(2 + flow_value.flownode_ids.len() * (source_table_ids.len() + 1)); - /// Builds flow name key + // Builds flow name key let flow_name = FlowNameKey::new(&flow_value.catalog_name, &flow_value.flow_name); keys.push(flow_name.to_bytes()); - /// Builds flow value key + // Builds flow value key let flow_info_key = FlowInfoKey::new(flow_id); keys.push(flow_info_key.to_bytes()); - /// Builds flownode flow keys & table flow keys + // Builds flownode flow keys & table flow keys flow_value .flownode_ids .iter() @@ -310,7 +310,6 @@ mod tests { } fn test_flow_info_value( - flow_id: FlowId, flow_name: &str, flownode_ids: BTreeMap, source_table_ids: Vec, @@ -339,8 +338,7 @@ mod tests { let mem_kv = Arc::new(MemoryKvBackend::default()); let flow_metadata_manager = FlowMetadataManager::new(mem_kv.clone()); let flow_id = 10; - let flow_value = - test_flow_info_value(flow_id, "flow", [(0, 1u64)].into(), vec![1024, 1025, 1026]); + let flow_value = test_flow_info_value("flow", [(0, 1u64)].into(), vec![1024, 1025, 1026]); flow_metadata_manager .create_flow_metadata(flow_id, flow_value.clone()) .await @@ -380,9 +378,7 @@ mod tests { let mem_kv = Arc::new(MemoryKvBackend::default()); let flow_metadata_manager = FlowMetadataManager::new(mem_kv); let flow_id = 10; - let catalog_name = "greptime"; - let flow_value = - test_flow_info_value(flow_id, "flow", [(0, 1u64)].into(), vec![1024, 1025, 1026]); + let flow_value = test_flow_info_value("flow", [(0, 1u64)].into(), vec![1024, 1025, 1026]); flow_metadata_manager .create_flow_metadata(flow_id, flow_value.clone()) .await @@ -401,8 +397,7 @@ mod tests { let flow_metadata_manager = FlowMetadataManager::new(mem_kv); let flow_id = 10; let catalog_name = "greptime"; - let flow_value = - test_flow_info_value(flow_id, "flow", [(0, 1u64)].into(), vec![1024, 1025, 1026]); + let flow_value = test_flow_info_value("flow", [(0, 1u64)].into(), vec![1024, 1025, 1026]); flow_metadata_manager .create_flow_metadata(flow_id, flow_value.clone()) .await @@ -436,9 +431,7 @@ mod tests { let mem_kv = Arc::new(MemoryKvBackend::default()); let flow_metadata_manager = FlowMetadataManager::new(mem_kv.clone()); let flow_id = 10; - let catalog_name = "greptime"; - let flow_value = - test_flow_info_value(flow_id, "flow", [(0, 1u64)].into(), vec![1024, 1025, 1026]); + let flow_value = test_flow_info_value("flow", [(0, 1u64)].into(), vec![1024, 1025, 1026]); flow_metadata_manager .create_flow_metadata(flow_id, flow_value.clone()) .await diff --git a/src/common/meta/src/key/flow/flow_name.rs b/src/common/meta/src/key/flow/flow_name.rs index 271a24f641..ba877d4fc1 100644 --- a/src/common/meta/src/key/flow/flow_name.rs +++ b/src/common/meta/src/key/flow/flow_name.rs @@ -12,9 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::sync::Arc; - -use api::v1::flow::flow_server::Flow; use lazy_static::lazy_static; use regex::Regex; use serde::{Deserialize, Serialize}; @@ -23,9 +20,7 @@ use snafu::OptionExt; use crate::error::{self, Result}; use crate::key::flow::FlowScoped; use crate::key::txn_helper::TxnOpGetResponseSet; -use crate::key::{ - txn_helper, DeserializedValueWithBytes, FlowId, MetaKey, TableMetaValue, NAME_PATTERN, -}; +use crate::key::{DeserializedValueWithBytes, FlowId, MetaKey, TableMetaValue, NAME_PATTERN}; use crate::kv_backend::txn::Txn; use crate::kv_backend::KvBackendRef; @@ -50,11 +45,13 @@ impl<'a> FlowNameKey<'a> { FlowNameKey(FlowScoped::new(inner)) } + #[cfg(test)] /// Returns the catalog. pub fn catalog(&self) -> &str { self.0.catalog_name } + #[cfg(test)] /// Return the `flow_name` pub fn flow_name(&self) -> &str { self.0.flow_name @@ -143,8 +140,6 @@ impl FlowNameValue { } } -pub type FlowNameManagerRef = Arc; - /// The manager of [FlowNameKey]. pub struct FlowNameManager { kv_backend: KvBackendRef, diff --git a/src/common/meta/src/key/flow/flownode_flow.rs b/src/common/meta/src/key/flow/flownode_flow.rs index d891fbbb05..8781cdaab2 100644 --- a/src/common/meta/src/key/flow/flownode_flow.rs +++ b/src/common/meta/src/key/flow/flownode_flow.rs @@ -79,6 +79,7 @@ impl FlownodeFlowKey { self.0.flow_id } + #[cfg(test)] /// Returns the [FlownodeId]. pub fn flownode_id(&self) -> FlownodeId { self.0.flownode_id @@ -150,8 +151,6 @@ impl<'a> MetaKey<'a, FlownodeFlowKeyInner> for FlownodeFlowKeyInner { } } -pub type FlownodeFlowManagerRef = Arc; - /// The manager of [FlownodeFlowKey]. pub struct FlownodeFlowManager { kv_backend: KvBackendRef, diff --git a/src/datanode/src/heartbeat/handler/close_region.rs b/src/datanode/src/heartbeat/handler/close_region.rs index eb0e9165d9..1925b2df6b 100644 --- a/src/datanode/src/heartbeat/handler/close_region.rs +++ b/src/datanode/src/heartbeat/handler/close_region.rs @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use common_error::ext::ErrorExt; use common_meta::instruction::{InstructionReply, SimpleReply}; use common_meta::RegionIdent; use common_telemetry::{tracing, warn}; @@ -47,7 +46,7 @@ impl HandlerContext { } Err(err) => InstructionReply::CloseRegion(SimpleReply { result: false, - error: Some(err.output_msg()), + error: Some(format!("{err:?}")), }), } }) diff --git a/src/datanode/src/heartbeat/handler/downgrade_region.rs b/src/datanode/src/heartbeat/handler/downgrade_region.rs index dbf5d72ffd..4dccdc26aa 100644 --- a/src/datanode/src/heartbeat/handler/downgrade_region.rs +++ b/src/datanode/src/heartbeat/handler/downgrade_region.rs @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use common_error::ext::ErrorExt; use common_meta::instruction::{DowngradeRegion, DowngradeRegionReply, InstructionReply}; use futures_util::future::BoxFuture; use store_api::region_engine::SetReadonlyResponse; @@ -43,7 +42,7 @@ impl HandlerContext { Err(err) => InstructionReply::DowngradeRegion(DowngradeRegionReply { last_entry_id: None, exists: true, - error: Some(err.output_msg()), + error: Some(format!("{err:?}")), }), } }) diff --git a/src/datanode/src/heartbeat/handler/open_region.rs b/src/datanode/src/heartbeat/handler/open_region.rs index a19ae955c6..7efab62c6e 100644 --- a/src/datanode/src/heartbeat/handler/open_region.rs +++ b/src/datanode/src/heartbeat/handler/open_region.rs @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use common_error::ext::ErrorExt; use common_meta::instruction::{InstructionReply, OpenRegion, SimpleReply}; use common_meta::wal_options_allocator::prepare_wal_options; use futures_util::future::BoxFuture; @@ -43,7 +42,7 @@ impl HandlerContext { }); let result = self.region_server.handle_request(region_id, request).await; let success = result.is_ok(); - let error = result.as_ref().map_err(|e| e.output_msg()).err(); + let error = result.as_ref().map_err(|e| format!("{e:?}")).err(); InstructionReply::OpenRegion(SimpleReply { result: success, error, diff --git a/src/datanode/src/heartbeat/handler/upgrade_region.rs b/src/datanode/src/heartbeat/handler/upgrade_region.rs index 76fa3327b5..dd95ee3c2b 100644 --- a/src/datanode/src/heartbeat/handler/upgrade_region.rs +++ b/src/datanode/src/heartbeat/handler/upgrade_region.rs @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use common_error::ext::ErrorExt; use common_meta::instruction::{InstructionReply, UpgradeRegion, UpgradeRegionReply}; use common_telemetry::{info, warn}; use futures_util::future::BoxFuture; @@ -107,7 +106,7 @@ impl HandlerContext { InstructionReply::UpgradeRegion(UpgradeRegionReply { ready: false, exists: true, - error: Some(err.output_msg()), + error: Some(format!("{err:?}")), }) } }