-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ISSUE #1303]🚀Add QueryAssignmentRequestBody and QueryAssignmentResponseBody #1304
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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, | ||
} | ||
} | ||
} |
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, | ||
} | ||
Comment on lines
+1
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Request and response bodies are properly structured but processor implementation is incomplete The QueryAssignmentRequestBody and QueryAssignmentResponseBody are well-defined, but the processor implementation in
🔗 Analysis chainVerify integration with QueryAssignmentResponseBody This request body should have a corresponding response body structure and proper integration points. Let me check the response body implementation to ensure proper integration. Let me check one more thing to verify if these types are properly integrated into the protocol/command system. Let me check one final thing to verify the query assignment processor implementation. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify the complete query assignment feature implementation
# Find the corresponding response body
fd -e rs "query_assignment_response_body"
# Check for handler/processor implementations
rg -l "QueryAssignmentRequestBody|QueryAssignmentResponseBody" --type rust
# Look for test files covering this functionality
fd -e rs "test.*query.*assignment"
Length of output: 364 Script: #!/bin/bash
# Check the response body implementation
cat rocketmq-remoting/src/protocol/body/query_assignment_response_body.rs
# Check if these types are used in any request/response handling code
rg -A 5 "QueryAssignmentRequestBody|QueryAssignmentResponseBody" --type rust
Length of output: 2282 Script: #!/bin/bash
# Check for command code and request/response type registration
rg -l "RemotingCommand|RequestCode" --type rust
# Then check the content of potential command registration files
ast-grep --pattern 'RequestCode::$_'
Length of output: 31228 Script: #!/bin/bash
# Check the query assignment processor implementation
cat rocketmq-broker/src/processor/query_assignment_processor.rs
# Check if QueryAssignment request code is properly registered
rg -A 5 "RequestCode::QueryAssignment" --type rust
Length of output: 1907 |
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>, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add documentation and consider implementing additional functionality
The structure definition needs the following improvements:
Add documentation like this:
Consider adding unit tests: