rocketmq_remoting/protocol/header/get_consume_stats_request_header.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 */
17use cheetah_string::CheetahString;
18use rocketmq_macros::RequestHeaderCodecV2;
19use serde::Deserialize;
20use serde::Serialize;
21
22use crate::rpc::topic_request_header::TopicRequestHeader;
23
24#[derive(Debug, Serialize, Deserialize, RequestHeaderCodecV2)]
25pub struct GetConsumeStatsRequestHeader {
26 #[serde(rename = "consumerGroup")]
27 pub consumer_group: CheetahString,
28 #[serde(rename = "topic")]
29 pub topic: CheetahString,
30 #[serde(flatten)]
31 pub topic_request_header: Option<TopicRequestHeader>,
32}
33
34impl GetConsumeStatsRequestHeader {
35 // pub const CONSUMER_GROUP: &'static str = "consumerGroup";
36 // pub const TOPIC: &'static str = "topic";
37
38 pub fn get_consumer_group(&self) -> &CheetahString {
39 &self.consumer_group
40 }
41 pub fn set_consumer_group(&mut self, consumer_group: CheetahString) {
42 self.consumer_group = consumer_group;
43 }
44
45 pub fn get_topic(&self) -> &CheetahString {
46 &self.topic
47 }
48 pub fn set_topic(&mut self, topic: CheetahString) {
49 self.topic = topic;
50 }
51}
52
53// impl CommandCustomHeader for GetConsumeStatsRequestHeader {
54// fn to_map(&self) -> Option<std::collections::HashMap<CheetahString, CheetahString>> {
55// let mut map = std::collections::HashMap::new();
56
57// map.insert(
58// CheetahString::from_static_str(Self::CONSUMER_GROUP),
59// self.consumer_group.clone(),
60// );
61// map.insert(
62// CheetahString::from_static_str(Self::TOPIC),
63// self.topic.clone(),
64// );
65// if let Some(value) = self.topic_request_header.as_ref() {
66// if let Some(value) = value.to_map() {
67// map.extend(value);
68// }
69// }
70// Some(map)
71// }
72// }
73
74// impl FromMap for GetConsumeStatsRequestHeader {
75// type Error = rocketmq_error::RocketmqError;
76
77// type Target = Self;
78
79// fn from(
80// map: &std::collections::HashMap<CheetahString, CheetahString>,
81// ) -> Result<Self::Target, Self::Error> {
82// Ok(GetConsumeStatsRequestHeader {
83// consumer_group: map
84// .get(&CheetahString::from_static_str(Self::CONSUMER_GROUP))
85// .cloned()
86// .unwrap_or_default(),
87// topic: map
88// .get(&CheetahString::from_static_str(Self::TOPIC))
89// .cloned()
90// .unwrap_or_default(),
91// topic_request_header: Some(<TopicRequestHeader as FromMap>::from(map)?),
92// })
93// }
94//}