-
Notifications
You must be signed in to change notification settings - Fork 82
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 ##656] 🎨Add ConsumeMessageContext struct and ConsumeMessageHook trait #657
Conversation
WalkthroughThe recent changes introduce new functionalities to the Changes
Sequence Diagram(s)sequenceDiagram
participant Consumer
participant Broker
participant Hook
Consumer->>Broker: Consume Message Request
Broker->>Hook: consume_message_before(context)
Hook-->>Broker: Before Hook Processed
Broker-->>Consumer: Process Message
Broker->>Hook: consume_message_after(context)
Hook-->>Broker: After Hook Processed
Assessment against linked issues
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
🚀Thanks for your contribution🎉. CodeRabbit(AI) will review your code first🔥 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #657 +/- ##
==========================================
- Coverage 26.02% 25.97% -0.05%
==========================================
Files 233 234 +1
Lines 17056 17079 +23
==========================================
- Hits 4438 4436 -2
- Misses 12618 12643 +25 ☔ View full report in Codecov by Sentry. |
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.
Actionable comments posted: 6
Outside diff range and nitpick comments (3)
rocketmq-broker/src/mqtrace/consume_message_hook.rs (3)
19-24
: Ensure clarity and consistency in documentation.The documentation for the
hook_name
method should explicitly mention the expected conventions or formats for the names, if any, to avoid confusion and ensure that all implementors follow a consistent naming strategy.
27-31
: Review and possibly enhance the documentation forconsume_message_before
.The documentation could be improved by specifying potential use cases or examples of what could be done in this method. This would help implementors understand how to effectively use this hook.
33-37
: Clarify the post-consumption hook documentation.It would be beneficial to provide more detailed examples of cleanup or logging tasks that could be performed in the
consume_message_after
method, aiding implementors in understanding how to make the most of this hook.
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (3)
- rocketmq-broker/src/mqtrace.rs (1 hunks)
- rocketmq-broker/src/mqtrace/consume_message_context.rs (1 hunks)
- rocketmq-broker/src/mqtrace/consume_message_hook.rs (1 hunks)
Files skipped from review due to trivial changes (1)
- rocketmq-broker/src/mqtrace.rs
Additional context used
GitHub Check: codecov/patch
rocketmq-broker/src/mqtrace/consume_message_context.rs
[warning] 23-23: rocketmq-broker/src/mqtrace/consume_message_context.rs#L23
Added line #L23 was not covered by tests
[warning] 25-33: rocketmq-broker/src/mqtrace/consume_message_context.rs#L25-L33
Added lines #L25 - L33 were not covered by tests
[warning] 35-35: rocketmq-broker/src/mqtrace/consume_message_context.rs#L35
Added line #L35 was not covered by tests
[warning] 37-43: rocketmq-broker/src/mqtrace/consume_message_context.rs#L37-L43
Added lines #L37 - L43 were not covered by tests
[warning] 45-48: rocketmq-broker/src/mqtrace/consume_message_context.rs#L45-L48
Added lines #L45 - L48 were not covered by tests
[warning] 50-50: rocketmq-broker/src/mqtrace/consume_message_context.rs#L50
Added line #L50 was not covered by tests
use rocketmq_common::common::config::TopicConfig; | ||
use rocketmq_store::stats::stats_type::StatsType; | ||
|
||
#[derive(Default)] |
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.
Add unit tests to cover the Default
trait implementation.
Given the complexity introduced with the new fields, it's crucial to ensure that the Default
trait behaves as expected.
Tools
GitHub Check: codecov/patch
[warning] 23-23: rocketmq-broker/src/mqtrace/consume_message_context.rs#L23
Added line #L23 was not covered by tests
pub consumer_group: String, | ||
pub topic: String, | ||
pub queue_id: Option<i32>, | ||
pub client_host: String, | ||
pub store_host: String, | ||
pub message_ids: HashMap<String, i64>, | ||
pub body_length: i32, | ||
pub success: bool, | ||
pub status: String, |
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.
Ensure comprehensive testing for the new fields in ConsumeMessageContext
.
The added fields such as consumer_group
, topic
, and queue_id
are critical for the context's integrity and functionality. Each field should be covered by unit tests to validate their default values and any other logic associated with them.
Tools
GitHub Check: codecov/patch
[warning] 25-33: rocketmq-broker/src/mqtrace/consume_message_context.rs#L25-L33
Added lines #L25 - L33 were not covered by tests
pub success: bool, | ||
pub status: String, | ||
//mq_trace_context: Option<Box<dyn std::any::Any>>, // Replace with actual type | ||
pub topic_config: Arc<TopicConfig>, |
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.
Cover the Arc<TopicConfig>
field with appropriate unit tests.
Testing the reference-counted topic_config
field is essential to ensure that it integrates correctly within the system and does not lead to unexpected behavior, especially with multi-threaded access.
Tools
GitHub Check: codecov/patch
[warning] 35-35: rocketmq-broker/src/mqtrace/consume_message_context.rs#L35
Added line #L35 was not covered by tests
pub account_auth_type: String, | ||
pub account_owner_parent: String, | ||
pub account_owner_self: String, | ||
pub rcv_msg_num: i32, | ||
pub rcv_msg_size: i32, | ||
pub rcv_stat: StatsType, | ||
pub commercial_rcv_msg_num: i32, |
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.
Include tests for new account and message statistics fields.
Fields like account_auth_type
, account_owner_parent
, and rcv_msg_num
play a significant role in the message consumption context. Proper testing is required to verify that they are handled correctly within the system.
Tools
GitHub Check: codecov/patch
[warning] 37-43: rocketmq-broker/src/mqtrace/consume_message_context.rs#L37-L43
Added lines #L37 - L43 were not covered by tests
pub commercial_owner: String, | ||
pub commercial_rcv_stats: StatsType, | ||
pub commercial_rcv_times: i32, | ||
pub commercial_rcv_size: i32, |
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.
Validate the commercial fields with targeted unit tests.
The commercial-related fields such as commercial_owner
and commercial_rcv_stats
need thorough testing to ensure their accuracy and proper handling in commercial scenarios.
Tools
GitHub Check: codecov/patch
[warning] 45-48: rocketmq-broker/src/mqtrace/consume_message_context.rs#L45-L48
Added lines #L45 - L48 were not covered by tests
pub commercial_rcv_times: i32, | ||
pub commercial_rcv_size: i32, | ||
|
||
pub namespace: String, |
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.
Test the namespace
field to ensure correct functionality.
The namespace
field is a critical addition that affects how messages are categorized and handled. It should be tested to confirm that it functions as intended across different namespaces.
Tools
GitHub Check: codecov/patch
[warning] 50-50: rocketmq-broker/src/mqtrace/consume_message_context.rs#L50
Added line #L50 was not covered by tests
Which Issue(s) This PR Fixes(Closes)
Fixes #656
Brief Description
How Did You Test This Change?
Summary by CodeRabbit