Conversation
|
🔊@mxsm 🚀Thanks for your contribution🎉! 💡CodeRabbit(AI) will review your code first🔥! Note 🚨The code review suggestions from CodeRabbit are to be used as a reference only, and the PR submitter can decide whether to make changes based on their own judgment. Ultimately, the project management personnel will conduct the final code review💥. |
WalkthroughAdds a new producer batch-send example: a Cargo.toml example entry plus a new Rust example implementing eight batch-send scenarios (variations of timeout, queue targeting, and callbacks). Changes
Sequence Diagram(s)sequenceDiagram
participant Example
participant Producer
participant NameServer
participant Broker
Example->>Producer: build & start producer
Producer->>NameServer: fetch topic routes / queues
NameServer-->>Producer: return queues
Example->>Producer: invoke batch_send / batch_send_with_callback (with optional queue/timeout)
Producer->>Broker: send batch request
Broker-->>Producer: send response / ack
Producer-->>Example: return result or invoke callback
Example->>Producer: shutdown
Producer-->>Broker: cleanup connections
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@rocketmq-example/examples/producer/batch_send.rs`:
- Line 159: The CI fails due to rustfmt violations in the producer example; run
`cargo fmt --all` and reformat the multi-line function signature
`batch_send_to_queue` and its call sites so they comply with rustfmt,
specifically reflow the `send_batch_to_queue_with_timeout` and
`send_batch_with_callback` invocations (and other multi-line calls around those
locations) to use the standard Rust multiline call formatting; ensure
`DefaultMQProducer` usage and argument lists are line-wrapped consistently so
`cargo fmt` passes.
🧹 Nitpick comments (2)
rocketmq-example/examples/producer/batch_send.rs (2)
232-239: Consider extracting the duplicated callback closure.The identical callback closure is repeated four times. For an example file, this is acceptable for readability, but you could reduce duplication with a small helper function.
♻️ Optional: extract shared callback
+fn batch_send_callback(result: Option<&SendResult>, error: Option<&dyn std::error::Error>) { + match (result, error) { + (Some(r), None) => println!(" Callback: Success - {:?}", r), + (None, Some(e)) => println!(" Callback: Error - {}", e), + _ => println!(" Callback: Unknown state"), + } +}Then use
batch_send_callbackin place of each inline closure.Also applies to: 266-273, 300-307, 334-341
54-56: Silent skip when no queues are available.If
fetch_publish_message_queuesreturns an empty list, scenarios 3, 4, 7, and 8 are silently skipped with no indication to the user. Consider printing a warning so the user understands why those examples didn't run.💡 Suggested improvement
let queues = producer.fetch_publish_message_queues(TOPIC).await?; let target_queue = queues.first().cloned(); + if target_queue.is_none() { + println!(" ⚠ No queues available for topic '{}', queue-specific examples will be skipped.", TOPIC); + }
rocketmq-rust-bot
left a comment
There was a problem hiding this comment.
LGTM - All CI checks passed ✅
Which Issue(s) This PR Fixes(Closes)
Brief Description
How Did You Test This Change?
Summary by CodeRabbit