-
Notifications
You must be signed in to change notification settings - Fork 27
fix: make queueMessages client option True by default
#652
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
WalkthroughRefactors realtime send logic to gate on a new state_should_queue set (includes INITIALIZED, DISCONNECTED, CONNECTING), changes Options.default Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
0c19425 to
534864e
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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
ably/realtime/connectionmanager.py(1 hunks)ably/types/options.py(1 hunks)test/ably/realtime/realtimechannel_publish_test.py(1 hunks)test/ably/realtime/realtimeconnection_test.py(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- test/ably/realtime/realtimeconnection_test.py
- ably/types/options.py
🧰 Additional context used
🧬 Code graph analysis (2)
ably/realtime/connectionmanager.py (3)
ably/realtime/connection.py (2)
state(101-103)state(112-113)ably/types/connectionstate.py (1)
ConnectionState(8-16)ably/types/options.py (2)
queue_messages(169-170)queue_messages(173-174)
test/ably/realtime/realtimechannel_publish_test.py (7)
ably/realtime/connectionmanager.py (2)
ably(738-739)state(742-743)ably/types/options.py (5)
use_binary_protocol(161-162)use_binary_protocol(165-166)queue_messages(169-170)queue_messages(173-174)auto_connect(250-251)ably/realtime/realtime.py (1)
connection(132-134)ably/util/eventemitter.py (1)
once_async(169-182)ably/types/connectionstate.py (1)
ConnectionState(8-16)ably/realtime/realtime_channel.py (3)
state(691-693)state(696-697)publish(388-488)ably/util/exceptions.py (1)
AblyException(9-84)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: check (3.11)
- GitHub Check: check (3.8)
- GitHub Check: check (3.12)
- GitHub Check: check (3.10)
- GitHub Check: check (3.14)
- GitHub Check: check (3.13)
- GitHub Check: check (3.9)
🔇 Additional comments (2)
ably/realtime/connectionmanager.py (1)
185-215: LGTM! Well-structured implementation of RTL6c2 state gating.The control flow correctly handles:
- Non-connectable states (CLOSING, CLOSED, FAILED, SUSPENDED) fail immediately at line 188-189.
- Queue-able states with
queue_messages=Falseand ack-required messages fail per RTL6c2.- msgSerial is only assigned after the RTL6c2 check, preventing serial number waste on rejected messages.
- The existing duplicate-prevention logic at line 220 in
_send_protocol_message_on_connected_statehandles the case where messages are both inpending_message_queueandqueued_messages.test/ably/realtime/realtimechannel_publish_test.py (1)
288-324: Good test coverage for RTL6c2 CONNECTING state behavior.The test correctly:
- Disables auto-connect to control the connection lifecycle
- Blocks the connection at CONNECTING state using a no-op coroutine
- Verifies the expected error code (90000) and status code (400)
- Ensures proper cleanup with
ably.close()
534864e to
4194243
Compare
4194243 to
6bbade8
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
♻️ Duplicate comments (1)
test/ably/realtime/realtimechannel_publish_test.py (1)
288-325: Make the error-message assertion case-insensitive to matchConnectionStatestring form.The setup of the CONNECTING state with
queue_messages=Falselooks good and exercises the new gate correctly. The assertion on the error message is fragile though:assert 'CONNECTING' in str(exc_info.value)
ConnectionState’s value is lowercase ('connecting'), so the formatted exception string won’t contain the all‑caps'CONNECTING', and this assertion will fail even when the behavior is correct. A case‑insensitive check is safer:- assert 'CONNECTING' in str(exc_info.value) + assert 'connecting' in str(exc_info.value).lower()
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (5)
ably/realtime/connectionmanager.py(2 hunks)ably/types/options.py(1 hunks)test/ably/realtime/realtimechannel_publish_test.py(1 hunks)test/ably/realtime/realtimeconnection_test.py(1 hunks)test/ably/utils.py(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- test/ably/realtime/realtimeconnection_test.py
- ably/types/options.py
- test/ably/utils.py
🧰 Additional context used
🧬 Code graph analysis (1)
ably/realtime/connectionmanager.py (3)
ably/types/connectionstate.py (1)
ConnectionState(8-16)ably/util/exceptions.py (1)
AblyException(9-84)ably/types/options.py (2)
queue_messages(169-170)queue_messages(173-174)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: check (3.14)
- GitHub Check: check (3.13)
- GitHub Check: check (3.10)
- GitHub Check: check (3.11)
- GitHub Check: check (3.12)
6bbade8 to
542ab42
Compare
- Add TO3g test verifying queueMessages defaults to true
- Add RTL6c2 check to fail immediately when queueMessages is false
and connection is CONNECTING/DISCONNECTED
- Add test for publish failure on CONNECTING state with queueMessages=false
542ab42 to
e98c2a1
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: 0
🧹 Nitpick comments (1)
test/ably/realtime/realtimechannel_publish_test.py (1)
288-307: Align test docstring with the actual INITIALIZED scenario.The test name and setup exercise the INITIALIZED state (
auto_connect=False), but the docstring still says “connection is CONNECTING”. For clarity, consider updating the docstring (and/or comment) to say INITIALIZED so it matches the scenario under test.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (5)
ably/realtime/connectionmanager.py(2 hunks)ably/realtime/realtime_channel.py(1 hunks)ably/types/options.py(1 hunks)test/ably/realtime/realtimechannel_publish_test.py(1 hunks)test/ably/realtime/realtimeconnection_test.py(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- test/ably/realtime/realtimeconnection_test.py
🧰 Additional context used
🧬 Code graph analysis (2)
ably/realtime/realtime_channel.py (1)
ably/types/connectionstate.py (1)
ConnectionState(8-16)
test/ably/realtime/realtimechannel_publish_test.py (4)
ably/types/options.py (4)
use_binary_protocol(161-162)use_binary_protocol(165-166)queue_messages(169-170)queue_messages(173-174)ably/types/channelsubscription.py (1)
channel(19-20)ably/realtime/realtime_channel.py (2)
get(742-767)publish(388-488)ably/util/exceptions.py (1)
AblyException(9-84)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: check (3.13)
- GitHub Check: check (3.11)
- GitHub Check: check (3.10)
- GitHub Check: check (3.8)
- GitHub Check: check (3.12)
- GitHub Check: check (3.14)
- GitHub Check: check (3.9)
🔇 Additional comments (3)
ably/types/options.py (1)
27-35: Defaultingqueue_messagesto True looks correct and localized.Constructor now defaults
queue_messages=Truewhile the rest of the option plumbing is unchanged; this aligns with the new tests and connection manager behavior without introducing extra side effects in this file.ably/realtime/realtime_channel.py (1)
498-505: IncludingINITIALIZEDin allowed publish states is consistent with new queuing semantics.Allowing publish in
ConnectionState.INITIALIZEDand deferring the actual queue/fail decision toConnectionManager.send_protocol_messagematches the new tests and RTL6c2 behavior, while still blocking clearly invalid states (CLOSING/CLOSED/FAILED/SUSPENDED).ably/realtime/connectionmanager.py (1)
185-213:state_should_queue+ RTL6c2 guard now match the intended semantics.The new
state_should_queueset (INITIALIZED, DISCONNECTED, CONNECTING) plus:
- rejecting sends when not CONNECTED and not in that set, and
- raising only when
state_should_queueis true andqueue_messagesis false,correctly implements “queue when allowed; fail immediately when queueing is disabled” and fixes the previously inverted condition. The queuing branch then enqueues
PendingMessageand awaits its future for ACK-required messages, which is consistent with existing pending/queued handling and the new tests.
owenpearson
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.
looks good!
Make
queueMessagesclient option True by defaultSummary by CodeRabbit
Changed Behavior
Tests
✏️ Tip: You can customize this high-level summary in your review settings.