-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ISSUE #1303]🚀Add QueryAssignmentRequestBody and QueryAssignmentRespo…
…nseBody
- Loading branch information
Showing
6 changed files
with
205 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
rocketmq-common/src/common/message/message_queue_assignment.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
use std::collections::HashMap; | ||
use std::hash::Hash; | ||
use std::hash::Hasher; | ||
|
||
use cheetah_string::CheetahString; | ||
use serde::Deserialize; | ||
use serde::Serialize; | ||
|
||
use crate::common::message::message_enum::MessageRequestMode; | ||
use crate::common::message::message_queue::MessageQueue; | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct MessageQueueAssignment { | ||
pub message_queue: Option<MessageQueue>, | ||
pub mode: MessageRequestMode, | ||
pub attachments: Option<HashMap<CheetahString, CheetahString>>, | ||
} | ||
|
||
impl Hash for MessageQueueAssignment { | ||
fn hash<H: Hasher>(&self, state: &mut H) { | ||
self.message_queue.hash(state); | ||
self.mode.hash(state); | ||
if let Some(ref attachments) = self.attachments { | ||
for (key, value) in attachments { | ||
key.hash(state); | ||
value.hash(state); | ||
} | ||
} | ||
} | ||
} | ||
|
||
impl Default for MessageQueueAssignment { | ||
fn default() -> Self { | ||
MessageQueueAssignment { | ||
message_queue: None, | ||
mode: MessageRequestMode::Pull, | ||
attachments: None, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
rocketmq-remoting/src/protocol/body/query_assignment_request_body.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
use cheetah_string::CheetahString; | ||
use serde::Deserialize; | ||
use serde::Serialize; | ||
|
||
use crate::protocol::heartbeat::message_model::MessageModel; | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize, Default)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct QueryAssignmentRequestBody { | ||
pub topic: CheetahString, | ||
pub consumer_group: CheetahString, | ||
pub client_id: CheetahString, | ||
pub strategy_name: CheetahString, | ||
pub message_model: MessageModel, | ||
} |
27 changes: 27 additions & 0 deletions
27
rocketmq-remoting/src/protocol/body/query_assignment_response_body.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
use std::collections::HashSet; | ||
|
||
use rocketmq_common::common::message::message_queue_assignment::MessageQueueAssignment; | ||
use serde::Deserialize; | ||
use serde::Serialize; | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize, Default)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct QueryAssignmentResponseBody { | ||
pub message_queue_assignments: HashSet<MessageQueueAssignment>, | ||
} |