Skip to content

Commit cf4b850

Browse files
[ISSUE #4160]⚡️Remove unused code from send_message_request_header.rs (#4166)
1 parent 026cc8a commit cf4b850

File tree

1 file changed

+0
-193
lines changed

1 file changed

+0
-193
lines changed

rocketmq-remoting/src/protocol/header/message_operation_header/send_message_request_header.rs

Lines changed: 0 additions & 193 deletions
Original file line numberDiff line numberDiff line change
@@ -62,199 +62,6 @@ pub struct SendMessageRequestHeader {
6262
pub topic_request_header: Option<TopicRequestHeader>,
6363
}
6464

65-
/*impl SendMessageRequestHeader {
66-
pub const PRODUCER_GROUP: &'static str = "producerGroup";
67-
pub const TOPIC: &'static str = "topic";
68-
pub const DEFAULT_TOPIC: &'static str = "defaultTopic";
69-
pub const DEFAULT_TOPIC_QUEUE_NUMS: &'static str = "defaultTopicQueueNums";
70-
pub const QUEUE_ID: &'static str = "queueId";
71-
pub const SYS_FLAG: &'static str = "sysFlag";
72-
pub const BORN_TIMESTAMP: &'static str = "bornTimestamp";
73-
pub const FLAG: &'static str = "flag";
74-
pub const PROPERTIES: &'static str = "properties";
75-
pub const RECONSUME_TIMES: &'static str = "reconsumeTimes";
76-
pub const UNIT_MODE: &'static str = "unitMode";
77-
pub const BATCH: &'static str = "batch";
78-
pub const MAX_RECONSUME_TIMES: &'static str = "maxReconsumeTimes";
79-
}
80-
81-
impl CommandCustomHeader for SendMessageRequestHeader {
82-
fn to_map(&self) -> Option<HashMap<CheetahString, CheetahString>> {
83-
let mut map = HashMap::from([
84-
(
85-
CheetahString::from_static_str(Self::PRODUCER_GROUP),
86-
self.producer_group.clone(),
87-
),
88-
(
89-
CheetahString::from_static_str(Self::TOPIC),
90-
self.topic.clone(),
91-
),
92-
(
93-
CheetahString::from_static_str(Self::DEFAULT_TOPIC),
94-
self.default_topic.clone(),
95-
),
96-
(
97-
CheetahString::from_static_str(Self::DEFAULT_TOPIC_QUEUE_NUMS),
98-
CheetahString::from_string(self.default_topic_queue_nums.to_string()),
99-
),
100-
(
101-
CheetahString::from_static_str(Self::SYS_FLAG),
102-
CheetahString::from_string(self.sys_flag.to_string()),
103-
),
104-
(
105-
CheetahString::from_static_str(Self::BORN_TIMESTAMP),
106-
CheetahString::from_string(self.born_timestamp.to_string()),
107-
),
108-
(
109-
CheetahString::from_static_str(Self::FLAG),
110-
CheetahString::from_string(self.flag.to_string()),
111-
),
112-
]);
113-
if let Some(ref queue_id) = self.queue_id {
114-
map.insert(
115-
CheetahString::from_static_str(Self::QUEUE_ID),
116-
CheetahString::from_string(queue_id.to_string()),
117-
);
118-
}
119-
if let Some(ref properties) = self.properties {
120-
map.insert(
121-
CheetahString::from_static_str(Self::PROPERTIES),
122-
properties.clone(),
123-
);
124-
}
125-
if let Some(ref reconsume_times) = self.reconsume_times {
126-
map.insert(
127-
CheetahString::from_static_str(Self::RECONSUME_TIMES),
128-
CheetahString::from_string(reconsume_times.to_string()),
129-
);
130-
}
131-
if let Some(ref unit_mode) = self.unit_mode {
132-
map.insert(
133-
CheetahString::from_static_str(Self::UNIT_MODE),
134-
CheetahString::from_string(unit_mode.to_string()),
135-
);
136-
}
137-
if let Some(ref batch) = self.batch {
138-
map.insert(
139-
CheetahString::from_static_str(Self::BATCH),
140-
CheetahString::from_string(batch.to_string()),
141-
);
142-
}
143-
if let Some(ref max_reconsume_times) = self.max_reconsume_times {
144-
map.insert(
145-
CheetahString::from_static_str(Self::MAX_RECONSUME_TIMES),
146-
CheetahString::from_string(max_reconsume_times.to_string()),
147-
);
148-
}
149-
if let Some(ref value) = self.topic_request_header {
150-
if let Some(value) = value.to_map() {
151-
map.extend(value);
152-
}
153-
}
154-
Some(map)
155-
}
156-
}
157-
158-
impl FromMap for SendMessageRequestHeader {
159-
type Error = rocketmq_error::RocketmqError;
160-
161-
type Target = Self;
162-
163-
fn from(map: &HashMap<CheetahString, CheetahString>) -> Result<Self::Target, Self::Error> {
164-
Ok(SendMessageRequestHeader {
165-
producer_group: map
166-
.get(&CheetahString::from_static_str(Self::PRODUCER_GROUP))
167-
.cloned()
168-
.ok_or(Self::Error::RemotingCommandError(
169-
"Miss producerGroup field".to_string(),
170-
))?,
171-
topic: map
172-
.get(&CheetahString::from_static_str(Self::TOPIC))
173-
.cloned()
174-
.ok_or(Self::Error::RemotingCommandError(
175-
"Miss topic field".to_string(),
176-
))?,
177-
default_topic: map
178-
.get(&CheetahString::from_static_str(Self::DEFAULT_TOPIC))
179-
.cloned()
180-
.ok_or(Self::Error::RemotingCommandError(
181-
"Miss defaultTopic field".to_string(),
182-
))?,
183-
default_topic_queue_nums: map
184-
.get(&CheetahString::from_static_str(
185-
Self::DEFAULT_TOPIC_QUEUE_NUMS,
186-
))
187-
.cloned()
188-
.ok_or(Self::Error::RemotingCommandError(
189-
"Miss defaultTopicQueueNums field".to_string(),
190-
))?
191-
.parse()
192-
.map_err(|_| {
193-
Self::Error::RemotingCommandError(
194-
"Parse defaultTopicQueueNums field error".to_string(),
195-
)
196-
})?,
197-
queue_id: Some(
198-
map.get(&CheetahString::from_static_str(Self::QUEUE_ID))
199-
.cloned()
200-
.ok_or(Self::Error::RemotingCommandError(
201-
"Miss queueId field".to_string(),
202-
))?
203-
.parse()
204-
.map_err(|_| {
205-
Self::Error::RemotingCommandError("Parse queueId field error".to_string())
206-
})?,
207-
),
208-
sys_flag: map
209-
.get(&CheetahString::from_static_str(Self::SYS_FLAG))
210-
.cloned()
211-
.ok_or(Self::Error::RemotingCommandError(
212-
"Miss sysFlag field".to_string(),
213-
))?
214-
.parse()
215-
.map_err(|_| {
216-
Self::Error::RemotingCommandError("Parse sysFlag field error".to_string())
217-
})?,
218-
born_timestamp: map
219-
.get(&CheetahString::from_static_str(Self::BORN_TIMESTAMP))
220-
.cloned()
221-
.ok_or(Self::Error::RemotingCommandError(
222-
"Miss bornTimestamp field".to_string(),
223-
))?
224-
.parse()
225-
.map_err(|_| {
226-
Self::Error::RemotingCommandError("Parse bornTimestamp field error".to_string())
227-
})?,
228-
flag: map
229-
.get(&CheetahString::from_static_str(Self::FLAG))
230-
.cloned()
231-
.ok_or(Self::Error::RemotingCommandError(
232-
"Miss flag field".to_string(),
233-
))?
234-
.parse()
235-
.map_err(|_| {
236-
Self::Error::RemotingCommandError("Parse flag field error".to_string())
237-
})?,
238-
properties: map
239-
.get(&CheetahString::from_static_str(Self::PROPERTIES))
240-
.cloned(),
241-
reconsume_times: map
242-
.get(&CheetahString::from_static_str(Self::RECONSUME_TIMES))
243-
.and_then(|v| v.parse().ok()),
244-
unit_mode: map
245-
.get(&CheetahString::from_static_str(Self::UNIT_MODE))
246-
.and_then(|v| v.parse().ok()),
247-
batch: map
248-
.get(&CheetahString::from_static_str(Self::BATCH))
249-
.and_then(|v| v.parse().ok()),
250-
max_reconsume_times: map
251-
.get(&CheetahString::from_static_str(Self::MAX_RECONSUME_TIMES))
252-
.and_then(|v| v.parse().ok()),
253-
topic_request_header: Some(<TopicRequestHeader as FromMap>::from(map)?),
254-
})
255-
}
256-
}*/
257-
25865
impl TopicRequestHeaderTrait for SendMessageRequestHeader {
25966
fn set_lo(&mut self, lo: Option<bool>) {
26067
self.topic_request_header.as_mut().unwrap().lo = lo;

0 commit comments

Comments
 (0)