-
Notifications
You must be signed in to change notification settings - Fork 42
[AIT-84] feat: add support for returning serials on publish
#1184
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
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds a typed PublishResult flow and Callback-based publish APIs for REST and Realtime channels, makes CompletionListener.ToCallback generic, updates internal publish implementations to return PublishResult-aware requests, and refactors tests to use publish-returned serials. Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
c4ffcd4 to
99a2c94
Compare
66c4061 to
e3a601c
Compare
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: 1
🤖 Fix all issues with AI agents
In
`@lib/src/test/java/io/ably/lib/test/realtime/RealtimeChannelMessageEditTest.java`:
- Around line 131-139: The test creates a Helpers.AsyncWaiter<PublishResult>
named publishResultAsyncWaiter but never passes it to channel.publish(), so
publishResultAsyncWaiter.waitFor() blocks; fix by calling channel.publish(...)
with publishResultAsyncWaiter as the callback parameter (i.e., pass
publishResultAsyncWaiter or its callback method into the channel.publish
invocation used to publish the "test_event" so PublishResult is delivered and
waitFor() can complete), then use publishResultAsyncWaiter.result to assert
serials.
🧹 Nitpick comments (2)
lib/src/test/java/io/ably/lib/test/rest/RestChannelMessageEditTest.java (1)
62-63: Consider adding null safety forserialsarray.
PublishResult.serialsis annotated as@Nullable. AccessingpublishResult.serials[0]directly risks an NPE if the server returns a null serials array. Consider assertingserials != nullfirst:assertNotNull("Expected serials array", publishResult.serials); assertNotNull("Expected message to have a serial", publishResult.serials[0]);This pattern should be applied consistently throughout the test file.
lib/src/main/java/io/ably/lib/realtime/ChannelBase.java (1)
447-455: Consider renaming for clarity.The method is named
callCompletionListenerErrorbut accepts aCallback<PublishResult>parameter. Consider renaming tocallCallbackErroror similar to avoid confusion with the existingCompletionListener-based overload at line 437.♻️ Suggested rename
- private static void callCompletionListenerError(Callback<PublishResult> listener, ErrorInfo err) { + private static void callCallbackError(Callback<PublishResult> listener, ErrorInfo err) {
lib/src/test/java/io/ably/lib/test/realtime/RealtimeChannelMessageEditTest.java
Show resolved
Hide resolved
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.
Pull request overview
This pull request adds support for returning message serials from publish operations. It introduces new publishWithResult and publishAsync APIs that return PublishResult objects containing message serials, and deprecates older CompletionListener-based methods in favor of Callback<PublishResult>.
Changes:
- Introduced
publishWithResultsynchronous API that returnsPublishResultwith message serials - Added new
publishAsyncmethods acceptingCallback<PublishResult>for asynchronous publishing with typed results - Deprecated
CompletionListener-based publish methods in favor of callback-based variants with better type safety
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/src/main/java/io/ably/lib/rest/ChannelBase.java | Added publishWithResult and publishAsync(Callback<PublishResult>) methods; deprecated older CompletionListener variants |
| lib/src/main/java/io/ably/lib/realtime/ChannelBase.java | Added new publish methods with Callback<PublishResult> parameter; deprecated CompletionListener variants |
| lib/src/main/java/io/ably/lib/realtime/CompletionListener.java | Made ToCallback generic to support different result types |
| lib/src/main/java/io/ably/lib/push/PushBase.java | Updated to use generic ToCallback<> with type parameter |
| android/src/main/java/io/ably/lib/push/PushChannel.java | Updated to use generic ToCallback<> with type parameter |
| lib/src/test/java/io/ably/lib/test/rest/RestChannelMessageEditTest.java | Updated tests to use publishWithResult and publishAsync with callback |
| lib/src/test/java/io/ably/lib/test/realtime/RealtimeChannelTest.java | Simplified publish calls by removing explicit null listeners |
| lib/src/test/java/io/ably/lib/test/realtime/RealtimeChannelMessageEditTest.java | Updated tests to use async publish with PublishResult callback |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lib/src/test/java/io/ably/lib/test/realtime/RealtimeChannelMessageEditTest.java
Show resolved
Hide resolved
lib/src/test/java/io/ably/lib/test/rest/RestChannelMessageEditTest.java
Outdated
Show resolved
Hide resolved
47b958f to
e61aff4
Compare
e3a601c to
0c2237b
Compare
e61aff4 to
4f2e3e5
Compare
- Introduced `publishWithResult` API to include message serials in the response. - Added callback-based `publishAsync` method for asynchronous publishing with serials. - Deprecated older `CompletionListener`-based publish methods in favor of `Callback<PublishResult>`.
0c2237b to
fc8250d
Compare
sacOO7
left a comment
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.
lgtm
Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
e7b8f72 to
982be70
Compare
publishWithResultAPI to include message serials in the response.publishAsyncmethod for asynchronous publishing with serials.CompletionListener-based publish methods in favor ofCallback<PublishResult>.Summary by CodeRabbit
New Features
Deprecations
Improvements
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.