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;
17
18use std::time::Duration;
19
20use common_base::readable_size::ReadableSize;
21pub use config::*;
22use serde::{Deserialize, Serialize};
23
24pub fn metadata_store_dir(store_dir: &str) -> String {
25 format!("{store_dir}/metadata")
26}
27
28/// The default data home directory.
29pub const DEFAULT_DATA_HOME: &str = "./greptimedb_data";
30
31#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
32#[serde(default)]
33pub struct KvBackendConfig {
34 /// The size of the metadata store backend log file.
35 pub file_size: ReadableSize,
36 /// The threshold of the metadata store size to trigger a purge.
37 pub purge_threshold: ReadableSize,
38 /// The interval of the metadata store to trigger a purge.
39 #[serde(with = "humantime_serde")]
40 pub purge_interval: Duration,
41}
42
43impl Default for KvBackendConfig {
44 fn default() -> Self {
45 Self {
46 // The log file size 64MB
47 file_size: ReadableSize::mb(64),
48 // The log purge threshold 256MB
49 purge_threshold: ReadableSize::mb(256),
50 // The log purge interval 1m
51 purge_interval: Duration::from_secs(60),
52 }
53 }
54}