Skip to content
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

RCOCOA-2305: Update base url to point to services.cloud.mongodb.com #8537

Merged
merged 7 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
x.y.z Release notes (yyyy-MM-dd)
=============================================================
### Enhancements
* None.
* The default base url in `AppConfiguration` has been updated to point to `services.cloud.mongodb.com`. See https://www.mongodb.com/docs/atlas/app-services/domain-migration/ for more information. ([#8512](https://github.com/realm/realm-swift/issues/8512))

### Fixed
* <How to hit and notice issue? what was the impact?> ([#????](https://github.com/realm/realm-swift/issues/????), since v?.?.?)
* None.
* Fix an assertion failure "m_lock_info && m_lock_info->m_file.get_path() == m_filename" that appears to be related to opening a Realm while the file is in the process of being closed on another thread. ([#8507](https://github.com/realm/realm-swift/issues/8507))
* Fixed diverging history due to a bug in the replication code when setting default null values (embedded objects included). ([Core #7536](https://github.com/realm/realm-core/issues/7536))
* Null pointer exception may be triggered when logging out and async commits callbacks not executed. ([Core #7434](https://github.com/realm/realm-core/issues/7434))
* `AppConfiguration.baseUrl` will now return the default value of the url when not set rather than `nil`. ([#8512](https://github.com/realm/realm-swift/issues/8512))

<!-- ### Breaking Changes - ONLY INCLUDE FOR NEW MAJOR version -->

Expand All @@ -17,7 +20,7 @@ x.y.z Release notes (yyyy-MM-dd)
* Xcode: 14.2-15.3.0.

### Internal
* Upgraded realm-core from ? to ?
* Upgraded realm-core from 14.4.1 to 14.5.0

10.49.1 Release notes (2024-03-22)
=============================================================
Expand All @@ -35,7 +38,7 @@ x.y.z Release notes (yyyy-MM-dd)

### Compatibility

* Realm Studio: 14.0.1 or later.
* Realm Studio: 15.0.0 or later.
* APIs are backwards compatible with all previous releases in the 10.x.y series.
* Carthage release for Swift is built with Xcode 15.3.0.
* CocoaPods: 1.10 or later.
Expand Down Expand Up @@ -97,7 +100,7 @@ restore the backup, or it will be deleted after three months.

### Compatibility

* Realm Studio: 14.0.1 or later.
* Realm Studio: 15.0.0 or later.
* APIs are backwards compatible with all previous releases in the 10.x.y series.
* Carthage release for Swift is built with Xcode 15.3.0.
* CocoaPods: 1.10 or later.
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import PackageDescription
import Foundation

let coreVersion = Version("14.4.1")
let coreVersion = Version("14.5.0")
let cocoaVersion = Version("10.49.1")

let cxxSettings: [CXXSetting] = [
Expand Down
11 changes: 11 additions & 0 deletions Realm/ObjectServerTests/SwiftObjectServerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,17 @@ class SwiftObjectServerTests: SwiftSyncTestCase {
RLMCredentials.anonymous())
}

func testAppBaseUrl() {
let appConfig = AppConfiguration()
XCTAssertEqual(appConfig.baseURL, "https://services.cloud.mongodb.com")

appConfig.baseURL = "https://foo.bar"
XCTAssertEqual(appConfig.baseURL, "https://foo.bar")

appConfig.baseURL = nil
XCTAssertEqual(appConfig.baseURL, "https://services.cloud.mongodb.com")
}

// MARK: - Authentication

func testInvalidCredentials() throws {
Expand Down
4 changes: 2 additions & 2 deletions Realm/RLMApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ typedef void(^RLMOptionalErrorBlock)(NSError * _Nullable);
/// will not have any effect.
@interface RLMAppConfiguration : NSObject <NSCopying>

/// A custom base URL to request against.
@property (nonatomic, strong, nullable) NSString *baseURL;
/// A custom base URL to request against. If not set or set to nil, the default base url for app services will be returned.
@property (nonatomic, strong, null_resettable) NSString *baseURL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the docstring should be updated to reflect that now we return the default url if there is no given base url, if we are going in that direction


/// The custom transport for network calls to the server.
@property (nonatomic, strong, nullable) id<RLMNetworkTransport> transport;
Expand Down
2 changes: 1 addition & 1 deletion Realm/RLMApp.mm
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ static void setOptionalString(std::optional<std::string>& dst, NSString *src) {
}

- (NSString *)baseURL {
return getOptionalString(_config.base_url);
return getOptionalString(_config.base_url) ?: RLMStringViewToNSString(app::App::default_base_url());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be done by Core, and return the default url if there is no given url

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it could, but they haven't done it 😄 I think it's a fair decision on their part as they probably want to keep the struct fairly simple and have the defaults be managed elsewhere.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the idea behind returning nil by default here was that most users shouldn't need to care what the base url is so we didn't even want to expose the default. The field in the core struct is optional specifically to support doing this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that most users shouldn't need to care, I am just not a huge fan of API where there's a default but it's not obvious what that is. I think returning it, even just for sanity checks is cleaner, but am open to being convinced otherwise.

}

- (void)setBaseURL:(nullable NSString *)baseURL {
Expand Down
6 changes: 4 additions & 2 deletions Realm/RLMAsyncTask.mm
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ void RLMSetAsyncOpenQueue(dispatch_queue_t queue) {
NSLocalizedDescriptionKey: @"Operation canceled"
}];

typedef void(^CoreProgressNotificationBlock)(NSUInteger transferredBytes, NSUInteger transferrableBytes, double estimate);

__attribute__((objc_direct_members))
@implementation RLMAsyncOpenTask {
RLMUnfairMutex _mutex;
std::shared_ptr<realm::AsyncOpenTask> _task;
std::vector<RLMProgressNotificationBlock> _progressBlocks;
std::vector<CoreProgressNotificationBlock> _progressBlocks;
bool _cancel;

RLMRealmConfiguration *_configuration;
Expand All @@ -57,7 +59,7 @@ @implementation RLMAsyncOpenTask {
}

- (void)addProgressNotificationOnQueue:(dispatch_queue_t)queue block:(RLMProgressNotificationBlock)block {
auto wrappedBlock = ^(NSUInteger transferred_bytes, NSUInteger transferrable_bytes) {
auto wrappedBlock = ^(NSUInteger transferred_bytes, NSUInteger transferrable_bytes, double) {
dispatch_async(queue, ^{
nirinchev marked this conversation as resolved.
Show resolved Hide resolved
@autoreleasepool {
block(transferred_bytes, transferrable_bytes);
Expand Down
2 changes: 1 addition & 1 deletion Realm/RLMSyncSession.mm
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ - (RLMProgressNotificationToken *)addProgressNotificationForDirection:(RLMSyncPr
? SyncSession::ProgressDirection::upload
: SyncSession::ProgressDirection::download);
bool is_streaming = (mode == RLMSyncProgressModeReportIndefinitely);
uint64_t token = session->register_progress_notifier([=](uint64_t transferred, uint64_t transferrable) {
uint64_t token = session->register_progress_notifier([=](uint64_t transferred, uint64_t transferrable, double) {
dispatch_async(queue, ^{
block((NSUInteger)transferred, (NSUInteger)transferrable);
});
Expand Down
2 changes: 1 addition & 1 deletion dependencies.list
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VERSION=10.49.1
REALM_CORE_VERSION=v14.4.1
REALM_CORE_VERSION=v14.5.0
STITCH_VERSION=8bf8ebcff6e804586c30a6ccbadb060753071a42
Loading