common_config/lib.rs
1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15pub mod config;
16pub mod error;
17pub mod file_watcher;
18mod tagged_seq;
19
20use std::time::Duration;
21
22use common_base::readable_size::ReadableSize;
23pub use config::*;
24use serde::{Deserialize, Serialize};
25
26pub fn metadata_store_dir(store_dir: &str) -> String {
27 format!("{store_dir}/metadata")
28}
29
30/// The default data home directory.
31pub const DEFAULT_DATA_HOME: &str = "./greptimedb_data";
32
33#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
34#[serde(default)]
35pub struct KvBackendConfig {
36 /// The size of the metadata store backend log file.
37 pub file_size: ReadableSize,
38 /// The threshold of the metadata store size to trigger a purge.
39 pub purge_threshold: ReadableSize,
40 /// The interval of the metadata store to trigger a purge.
41 #[serde(with = "humantime_serde")]
42 pub purge_interval: Duration,
43}
44
45impl Default for KvBackendConfig {
46 fn default() -> Self {
47 Self {
48 // The log file size 64MB
49 file_size: ReadableSize::mb(64),
50 // The log purge threshold 256MB
51 purge_threshold: ReadableSize::mb(256),
52 // The log purge interval 1m
53 purge_interval: Duration::from_secs(60),
54 }
55 }
56}