From 93e019e8b3d0ac4939802cb71627dc7457e5c042 Mon Sep 17 00:00:00 2001 From: masonyc Date: Fri, 13 Oct 2023 11:55:38 +1300 Subject: [PATCH] fix: humantime serde on heartbeat --- src/cmd/src/datanode.rs | 23 +++++++++++++++++------ src/servers/src/heartbeat_options.rs | 2 ++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/cmd/src/datanode.rs b/src/cmd/src/datanode.rs index b21aa38f5faa..b61220dfcaed 100644 --- a/src/cmd/src/datanode.rs +++ b/src/cmd/src/datanode.rs @@ -180,6 +180,7 @@ mod tests { use common_base::readable_size::ReadableSize; use common_test_util::temp_dir::create_named_temp_file; use datanode::config::{CompactionConfig, FileConfig, ObjectStoreConfig, RegionManifestConfig}; + use servers::heartbeat_options::HeartbeatOptions; use servers::Mode; use super::*; @@ -196,6 +197,9 @@ mod tests { rpc_hostname = "127.0.0.1" rpc_runtime_size = 8 + [heartbeat] + interval = "300ms" + [meta_client] metasrv_addrs = ["127.0.0.1:3002"] timeout = "3s" @@ -249,19 +253,26 @@ mod tests { assert_eq!(1024 * 1024 * 1024 * 50, options.wal.purge_threshold.0); assert!(!options.wal.sync_write); + let HeartbeatOptions { + interval: heart_beat_interval, + .. + } = options.heartbeat; + + assert_eq!(300, heart_beat_interval.as_millis()); + let MetaClientOptions { metasrv_addrs: metasrv_addr, - timeout: timeout_millis, - connect_timeout: connect_timeout_millis, + timeout, + connect_timeout, + ddl_timeout, tcp_nodelay, - ddl_timeout: ddl_timeout_millis, .. } = options.meta_client.unwrap(); assert_eq!(vec!["127.0.0.1:3002".to_string()], metasrv_addr); - assert_eq!(5000, connect_timeout_millis.as_millis()); - assert_eq!(10000, ddl_timeout_millis.as_millis()); - assert_eq!(3000, timeout_millis.as_millis()); + assert_eq!(5000, connect_timeout.as_millis()); + assert_eq!(10000, ddl_timeout.as_millis()); + assert_eq!(3000, timeout.as_millis()); assert!(tcp_nodelay); assert_eq!("/tmp/greptimedb/", options.storage.data_home); assert!(matches!( diff --git a/src/servers/src/heartbeat_options.rs b/src/servers/src/heartbeat_options.rs index 59d81e4e5c3d..bb7d34e18c3e 100644 --- a/src/servers/src/heartbeat_options.rs +++ b/src/servers/src/heartbeat_options.rs @@ -20,7 +20,9 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] #[serde(default)] pub struct HeartbeatOptions { + #[serde(with = "humantime_serde")] pub interval: Duration, + #[serde(with = "humantime_serde")] pub retry_interval: Duration, }