Skip to main content

common_wal/options/
kafka.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 serde::{Deserialize, Serialize};
16
17/// Kafka wal options allocated to a region.
18#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
19pub struct KafkaWalOptions {
20    /// Kafka wal topic.
21    pub topic: String,
22    /// Initial pruned entry id of the topic when this option is allocated.
23    ///
24    /// This is a create-time hint for initializing a new region's flushed entry id,
25    /// not the authoritative latest pruned entry id of the topic.
26    #[serde(default, skip_serializing_if = "Option::is_none")]
27    pub initial_pruned_entry_id: Option<u64>,
28}
29
30impl KafkaWalOptions {
31    /// Creates kafka WAL options with the topic only.
32    pub fn new(topic: String) -> Self {
33        Self {
34            topic,
35            initial_pruned_entry_id: None,
36        }
37    }
38}