mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-04 12:02:55 +00:00
Add default value for safekeeper --recall option. DEFAULT_RECALL_PERIOD is 1 second.
This commit is contained in:
@@ -112,7 +112,7 @@ fn main() -> Result<()> {
|
||||
}
|
||||
|
||||
if let Some(recall) = arg_matches.value_of("recall") {
|
||||
conf.recall_period = Some(humantime::parse_duration(recall)?);
|
||||
conf.recall_period = humantime::parse_duration(recall)?;
|
||||
}
|
||||
|
||||
start_safekeeper(conf)
|
||||
|
||||
@@ -200,9 +200,6 @@ impl Drop for SubscriptionStateInner {
|
||||
}
|
||||
|
||||
pub async fn main_loop(conf: SafeKeeperConf, mut rx: Receiver<CallmeEvent>) -> Result<()> {
|
||||
let default_timeout = Duration::from_secs(5);
|
||||
let recall_period = conf.recall_period.unwrap_or(default_timeout);
|
||||
|
||||
let subscriptions: Mutex<HashMap<(ZTenantId, ZTimelineId), SubscriptionState>> =
|
||||
Mutex::new(HashMap::new());
|
||||
|
||||
@@ -259,7 +256,7 @@ pub async fn main_loop(conf: SafeKeeperConf, mut rx: Receiver<CallmeEvent>) -> R
|
||||
},
|
||||
}
|
||||
},
|
||||
_ = tokio::time::sleep(recall_period) => { true },
|
||||
_ = tokio::time::sleep(conf.recall_period) => { true },
|
||||
};
|
||||
|
||||
if call_iteration {
|
||||
@@ -268,7 +265,7 @@ pub async fn main_loop(conf: SafeKeeperConf, mut rx: Receiver<CallmeEvent>) -> R
|
||||
for (&(_tenantid, _timelineid), state) in subscriptions.iter() {
|
||||
let listen_pg_addr = conf.listen_pg_addr.clone();
|
||||
|
||||
state.call(recall_period, listen_pg_addr);
|
||||
state.call(conf.recall_period, listen_pg_addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,14 @@ pub mod wal_service;
|
||||
|
||||
pub mod defaults {
|
||||
use const_format::formatcp;
|
||||
use std::time::Duration;
|
||||
|
||||
pub const DEFAULT_PG_LISTEN_PORT: u16 = 5454;
|
||||
pub const DEFAULT_PG_LISTEN_ADDR: &str = formatcp!("127.0.0.1:{DEFAULT_PG_LISTEN_PORT}");
|
||||
|
||||
pub const DEFAULT_HTTP_LISTEN_PORT: u16 = 7676;
|
||||
pub const DEFAULT_HTTP_LISTEN_ADDR: &str = formatcp!("127.0.0.1:{DEFAULT_HTTP_LISTEN_PORT}");
|
||||
pub const DEFAULT_RECALL_PERIOD: Duration = Duration::from_secs(1);
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -41,7 +43,7 @@ pub struct SafeKeeperConf {
|
||||
pub listen_pg_addr: String,
|
||||
pub listen_http_addr: String,
|
||||
pub ttl: Option<Duration>,
|
||||
pub recall_period: Option<Duration>,
|
||||
pub recall_period: Duration,
|
||||
}
|
||||
|
||||
impl SafeKeeperConf {
|
||||
@@ -62,7 +64,7 @@ impl Default for SafeKeeperConf {
|
||||
listen_pg_addr: defaults::DEFAULT_PG_LISTEN_ADDR.to_string(),
|
||||
listen_http_addr: defaults::DEFAULT_PG_LISTEN_ADDR.to_string(),
|
||||
ttl: None,
|
||||
recall_period: None,
|
||||
recall_period: defaults::DEFAULT_RECALL_PERIOD,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user