rocketmq_remoting/protocol/static_topic/
topic_queue_info.rs

1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18use std::collections::HashMap;
19
20use cheetah_string::CheetahString;
21use rocketmq_common::common::mix_all::METADATA_SCOPE_GLOBAL;
22use serde::Deserialize;
23use serde::Serialize;
24
25#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
26pub struct TopicQueueMappingInfo {
27    pub topic: Option<CheetahString>,
28    pub scope: Option<CheetahString>,
29    #[serde(rename = "totalQueues")]
30    pub total_queues: i32,
31    pub bname: Option<CheetahString>,
32    pub epoch: i64,
33    pub dirty: bool,
34    #[serde(rename = "currIdMap")]
35    pub curr_id_map: Option<HashMap<i32, i32>>,
36}
37
38impl Default for TopicQueueMappingInfo {
39    fn default() -> Self {
40        Self {
41            topic: None,
42            scope: Some(CheetahString::from_static_str(METADATA_SCOPE_GLOBAL)),
43            total_queues: 0,
44            bname: None,
45            epoch: 0,
46            dirty: false,
47            curr_id_map: None,
48        }
49    }
50}
51
52impl TopicQueueMappingInfo {
53    pub fn new(topic: CheetahString, total_queues: i32, bname: CheetahString, epoch: i64) -> Self {
54        Self {
55            topic: Some(topic),
56            scope: Some(CheetahString::from_static_str(METADATA_SCOPE_GLOBAL)),
57            total_queues,
58            bname: Some(bname),
59            epoch,
60            dirty: false,
61            curr_id_map: None,
62        }
63    }
64}