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 serde::{Deserialize, Serialize};
18
19use crate::config::kafka::common::{
20 KafkaConnectionConfig, KafkaTopicConfig, DEFAULT_AUTO_PRUNE_INTERVAL,
21 DEFAULT_AUTO_PRUNE_PARALLELISM, DEFAULT_TRIGGER_FLUSH_THRESHOLD,
22};
23
24/// Kafka wal configurations for metasrv.
25#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
26#[serde(default)]
27pub struct MetasrvKafkaConfig {
28 /// The kafka connection config.
29 #[serde(flatten)]
30 pub connection: KafkaConnectionConfig,
31 /// The kafka config.
32 #[serde(flatten)]
33 pub kafka_topic: KafkaTopicConfig,
34 // Automatically create topics for WAL.
35 pub auto_create_topics: bool,
36 // Interval of WAL pruning.
37 #[serde(with = "humantime_serde")]
38 pub auto_prune_interval: Duration,
39 // Threshold for sending flush request when pruning remote WAL.
40 // `None` stands for never sending flush request.
41 pub trigger_flush_threshold: u64,
42 // Limit of concurrent active pruning procedures.
43 pub auto_prune_parallelism: usize,
44}
45
46impl Default for MetasrvKafkaConfig {
47 fn default() -> Self {
48 Self {
49 connection: Default::default(),
50 kafka_topic: Default::default(),
51 auto_create_topics: true,
52 auto_prune_interval: DEFAULT_AUTO_PRUNE_INTERVAL,
53 trigger_flush_threshold: DEFAULT_TRIGGER_FLUSH_THRESHOLD,
54 auto_prune_parallelism: DEFAULT_AUTO_PRUNE_PARALLELISM,
55 }
56 }
57}