rocketmq_remoting/protocol/static_topic/
topic_queue_info.rs1use 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}