common_wal/config/kafka/
metasrv.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
15use std::time::Duration;
16
17use common_base::readable_size::ReadableSize;
18use serde::{Deserialize, Serialize};
19
20use crate::config::kafka::common::{
21    KafkaConnectionConfig, KafkaTopicConfig, DEFAULT_AUTO_PRUNE_INTERVAL,
22    DEFAULT_AUTO_PRUNE_PARALLELISM, DEFAULT_CHECKPOINT_TRIGGER_SIZE, DEFAULT_FLUSH_TRIGGER_SIZE,
23};
24
25/// Kafka wal configurations for metasrv.
26#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
27#[serde(default)]
28pub struct MetasrvKafkaConfig {
29    /// The kafka connection config.
30    #[serde(flatten)]
31    pub connection: KafkaConnectionConfig,
32    /// The kafka config.
33    #[serde(flatten)]
34    pub kafka_topic: KafkaTopicConfig,
35    // Automatically create topics for WAL.
36    pub auto_create_topics: bool,
37    // Interval of WAL pruning.
38    #[serde(with = "humantime_serde")]
39    pub auto_prune_interval: Duration,
40    // Limit of concurrent active pruning procedures.
41    pub auto_prune_parallelism: usize,
42    // The size of WAL to trigger flush.
43    pub flush_trigger_size: ReadableSize,
44    // The checkpoint trigger size.
45    pub checkpoint_trigger_size: ReadableSize,
46}
47
48impl Default for MetasrvKafkaConfig {
49    fn default() -> Self {
50        Self {
51            connection: Default::default(),
52            kafka_topic: Default::default(),
53            auto_create_topics: true,
54            auto_prune_interval: DEFAULT_AUTO_PRUNE_INTERVAL,
55            auto_prune_parallelism: DEFAULT_AUTO_PRUNE_PARALLELISM,
56            flush_trigger_size: DEFAULT_FLUSH_TRIGGER_SIZE,
57            checkpoint_trigger_size: DEFAULT_CHECKPOINT_TRIGGER_SIZE,
58        }
59    }
60}