use std::path::PathBuf;
pub fn get_store_path_consume_queue(root_dir: &str) -> String {
PathBuf::from(root_dir)
.join("consumequeue")
.to_string_lossy()
.into_owned()
}
pub fn get_store_path_rocksdb_consume_queue(root_dir: &str) -> String {
PathBuf::from(root_dir)
.join("consumequeue_rocksdb")
.to_string_lossy()
.into_owned()
}
pub fn get_store_path_consume_queue_ext(root_dir: &str) -> String {
PathBuf::from(root_dir)
.join("consumequeue_ext")
.to_string_lossy()
.into_owned()
}
pub fn get_store_path_batch_consume_queue(root_dir: &str) -> String {
PathBuf::from(root_dir)
.join("batchconsumequeue")
.to_string_lossy()
.into_owned()
}
pub fn get_store_path_index(root_dir: &str) -> String {
PathBuf::from(root_dir).join("index").to_string_lossy().into_owned()
}
pub fn get_store_checkpoint(root_dir: &str) -> String {
PathBuf::from(root_dir)
.join("checkpoint")
.to_string_lossy()
.into_owned()
}
pub fn get_abort_file(root_dir: &str) -> String {
PathBuf::from(root_dir).join("abort").to_string_lossy().into_owned()
}
pub fn get_lock_file(root_dir: &str) -> String {
PathBuf::from(root_dir).join("lock").to_string_lossy().into_owned()
}
pub fn get_delay_offset_store_path(root_dir: &str) -> String {
PathBuf::from(root_dir)
.join("config")
.join("delayOffset.json")
.to_string_lossy()
.into_owned()
}
pub fn get_timer_check_path(root_dir: &str) -> String {
PathBuf::from(root_dir)
.join("config")
.join("timercheck")
.to_string_lossy()
.into_owned()
}
pub fn get_timer_metrics_path(root_dir: &str) -> String {
PathBuf::from(root_dir)
.join("config")
.join("timermetrics")
.to_string_lossy()
.into_owned()
}
pub fn get_timer_log_path(root_dir: &str) -> String {
PathBuf::from(root_dir).join("timerlog").to_string_lossy().into_owned()
}
pub fn get_timer_wheel_path(root_dir: &str) -> String {
PathBuf::from(root_dir)
.join("timerwheel")
.to_string_lossy()
.into_owned()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_get_store_paths() {
let root_dir = "/tmp/test_storage";
assert_eq!(
get_store_path_consume_queue(root_dir),
PathBuf::from(root_dir)
.join("consumequeue")
.to_string_lossy()
.into_owned()
);
assert_eq!(
get_store_path_rocksdb_consume_queue(root_dir),
PathBuf::from(root_dir)
.join("consumequeue_rocksdb")
.to_string_lossy()
.into_owned()
);
assert_eq!(
get_store_path_consume_queue_ext(root_dir),
PathBuf::from(root_dir)
.join("consumequeue_ext")
.to_string_lossy()
.into_owned()
);
assert_eq!(
get_store_path_batch_consume_queue(root_dir),
PathBuf::from(root_dir)
.join("batchconsumequeue")
.to_string_lossy()
.into_owned()
);
assert_eq!(
get_store_path_index(root_dir),
PathBuf::from(root_dir).join("index").to_string_lossy().into_owned()
);
assert_eq!(
get_store_checkpoint(root_dir),
PathBuf::from(root_dir)
.join("checkpoint")
.to_string_lossy()
.into_owned()
);
assert_eq!(
get_abort_file(root_dir),
PathBuf::from(root_dir).join("abort").to_string_lossy().into_owned()
);
assert_eq!(
get_lock_file(root_dir),
PathBuf::from(root_dir).join("lock").to_string_lossy().into_owned()
);
assert_eq!(
get_delay_offset_store_path(root_dir),
PathBuf::from(root_dir)
.join("config")
.join("delayOffset.json")
.to_string_lossy()
.into_owned()
);
assert_eq!(
get_timer_check_path(root_dir),
PathBuf::from(root_dir)
.join("config")
.join("timercheck")
.to_string_lossy()
.into_owned()
);
assert_eq!(
get_timer_metrics_path(root_dir),
PathBuf::from(root_dir)
.join("config")
.join("timermetrics")
.to_string_lossy()
.into_owned()
);
assert_eq!(
get_timer_log_path(root_dir),
PathBuf::from(root_dir).join("timerlog").to_string_lossy().into_owned()
);
assert_eq!(
get_timer_wheel_path(root_dir),
PathBuf::from(root_dir)
.join("timerwheel")
.to_string_lossy()
.into_owned()
);
}
}