-
Notifications
You must be signed in to change notification settings - Fork 25
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
[ECO-5190] Fallbacks in custom environment #2017
base: main
Are you sure you want to change the base?
Conversation
…s nil by default (and for production) and translates to an empty string in swift. Since `fallbackHostsWithEnvironment:` accepts nil, so `ARTClientOptions.environment` should be nullable (TO3k1). But this is breaking change, thus using workaround. I haven't created an issue, since https://sdk.ably.com/builds/ably/specification/main/features/#TO3k1 is marked as deprecated.
…k hosts. The old check didn't take into account that there might be an environment prefix.
…t. I'm not sure why all errors with `kCFErrorDomainCFNetwork` domain should be considered as "no internet", since library itself treats it as "host unreachable" in `ARTWebSocketTransport.classifyError`. Thus skipping the test.
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 SwiftLint (0.57.0)Test/Tests/RealtimeClientConnectionTests.swift[ WalkthroughThe pull request introduces modifications to the Ably Realtime client's host fallback mechanism. In the Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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 (3)
Test/Tests/RealtimeClientConnectionTests.swift (2)
Line range hint
3841-3892
: Consider removing or updating the deprecated test function.The function
test__086__Connection__Host_Fallback__failing_connections_with_custom_endpoint_should_result_in_an_error_immediately()
is marked as deprecated. To maintain a clean codebase, consider updating the test to avoid using deprecated properties or removing it if it's no longer necessary.
Line range hint
4045-4055
: Review the decision to skip this test function.The test function
skipped_test__102__Connection__Host_Fallback__should_move_to_disconnected_when_there_s_no_internet__with_any_kCFErrorDomainCFNetwork()
has been prefixed withskipped_
, effectively skipping it. Please review whether this test is still needed. If it is obsolete, consider removing it entirely. If it requires fixes, address them to re-enable the test.Source/ARTRealtime.m (1)
1640-1640
: Consider using a more robust host comparison method.The current implementation uses string suffix comparison to identify the default realtime host. This could be fragile if the host string contains multiple occurrences of the default host pattern.
Consider using a more robust comparison method, such as:
-if (!_fallbacks && [transportError.url.host hasSuffix:[ARTDefault realtimeHost]]) { +if (!_fallbacks && [self isDefaultRealtimeHost:transportError.url.host]) {And add a helper method:
- (BOOL)isDefaultRealtimeHost:(NSString *)host { NSString *defaultHost = [ARTDefault realtimeHost]; return [host hasSuffix:defaultHost] && (host.length == defaultHost.length || [host characterAtIndex:host.length - defaultHost.length - 1] == '.'); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
Source/ARTDefault.m
(1 hunks)Source/ARTRealtime.m
(1 hunks)Test/Tests/RealtimeClientConnectionTests.swift
(8 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: check (macOS, test_macOS)
- GitHub Check: check (tvOS, test_tvOS17_2)
- GitHub Check: check
- GitHub Check: build
- GitHub Check: check (iOS, test_iOS17_2)
- GitHub Check: check
🔇 Additional comments (7)
Test/Tests/RealtimeClientConnectionTests.swift (5)
4144-4146
: LGTM!The assertions correctly verify the order of URL connections in the host fallback mechanism.
4149-4152
: LGTM!The new test function for the production environment appropriately extends the test coverage.
4241-4244
: LGTM!The addition of the test function for the production environment correctly tests the retry logic in host fallback.
4441-4441
: LGTM!The regular expression in the assertion accurately matches the expected URL pattern for fallback hosts, including optional 'sandbox-' and '-fallback' prefixes.
4093-4097
:⚠️ Potential issueFix the optional binding syntax in
if let env
statement.In line 4095, the
if let
statement is missing the assignment to unwrap the optionalenv
. The correct syntax isif let env = env {
. Please update the code to fix this syntax error.Apply this diff to fix the syntax error:
- if let env { + if let env = env {Likely invalid or redundant comment.
Source/ARTDefault.m (1)
28-30
: LGTM!The added conditional check correctly handles empty environment strings by setting them to
nil
. This ensures that fallback hosts are generated properly without unintended prefixes.Source/ARTRealtime.m (1)
Line range hint
1-1800
: LGTM! The implementation is robust and well-structured.The code demonstrates good practices in terms of:
- Comprehensive error handling
- Proper connection state management
- Detailed logging for debugging
- Clean memory management
Closes #2009
Summary by CodeRabbit
Release Notes
New Features
ARTRealtime
instances with different parametersBug Fixes
Tests