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

Avoid app caching #711

Merged
merged 1 commit into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions lib/src/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ class App {
String get id => realmCore.appGetId(this);

/// Create an app with a particular [AppConfiguration]
App(AppConfiguration configuration) : this._(_getApp(configuration));
App(AppConfiguration configuration) : this._(_createApp(configuration));

App._(this._handle);

static AppHandle _getApp(AppConfiguration configuration) {
configuration.baseFilePath.createSync(recursive: true);
return realmCore.getApp(configuration);
static AppHandle _createApp(AppConfiguration configuration) {
configuration.baseFilePath.createSync(recursive: true);
return realmCore.createApp(configuration);
}

/// Logs in a user with the given credentials.
Expand Down
25 changes: 25 additions & 0 deletions lib/src/native/realm_bindings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,27 @@ class RealmLibrary {
void Function(
ffi.Pointer<realm_app_config_t>, ffi.Pointer<ffi.Char>)>();

/// Create realm_app_t* instance given a valid realm configuration and sync client configuration.
///
/// @return A non-null pointer if no error occurred.
ffi.Pointer<realm_app_t> realm_app_create(
ffi.Pointer<realm_app_config_t> arg0,
ffi.Pointer<realm_sync_client_config_t> arg1,
) {
return _realm_app_create(
arg0,
arg1,
);
}

late final _realm_app_createPtr = _lookup<
ffi.NativeFunction<
ffi.Pointer<realm_app_t> Function(ffi.Pointer<realm_app_config_t>,
ffi.Pointer<realm_sync_client_config_t>)>>('realm_app_create');
late final _realm_app_create = _realm_app_createPtr.asFunction<
ffi.Pointer<realm_app_t> Function(ffi.Pointer<realm_app_config_t>,
ffi.Pointer<realm_sync_client_config_t>)>();

ffi.Pointer<realm_app_credentials_t> realm_app_credentials_new_anonymous() {
return _realm_app_credentials_new_anonymous();
}
Expand Down Expand Up @@ -846,6 +867,8 @@ class RealmLibrary {
ffi.Pointer<ffi.Void>,
realm_free_userdata_func_t)>();

/// @note this API will be removed and it is now deprecated in favour of realm_app_create
///
/// Get an existing @a realm_app_t* instance with the same app id, or create it with the
/// configuration if it doesn't exist.
///
Expand Down Expand Up @@ -923,6 +946,8 @@ class RealmLibrary {
late final _realm_app_get_app_id = _realm_app_get_app_idPtr
.asFunction<ffi.Pointer<ffi.Char> Function(ffi.Pointer<realm_app_t>)>();

/// @note this API will be removed and it is now deprecated in favour of realm_app_create
///
/// Get an existing @a realm_app_t* instance from the cache.
///
/// @return Cached app instance, or null if no cached app exists for this @a app_id.
Expand Down
4 changes: 2 additions & 2 deletions lib/src/native/realm_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1086,11 +1086,11 @@ class _RealmCore {
});
}

AppHandle getApp(AppConfiguration configuration) {
AppHandle createApp(AppConfiguration configuration) {
final httpTransportHandle = _createHttpTransport(configuration.httpClient);
final appConfigHandle = _createAppConfig(configuration, httpTransportHandle);
final syncClientConfigHandle = _createSyncClientConfig(configuration);
final realmAppPtr = _realmLib.invokeGetPointer(() => _realmLib.realm_app_get(appConfigHandle._pointer, syncClientConfigHandle._pointer));
final realmAppPtr = _realmLib.invokeGetPointer(() => _realmLib.realm_app_create(appConfigHandle._pointer, syncClientConfigHandle._pointer));
return AppHandle._(realmAppPtr);
}

Expand Down
2 changes: 1 addition & 1 deletion src/realm-core
Submodule realm-core updated 53 files
+26 −0 CHANGELOG.md
+3 −11 CMakeLists.txt
+52 −72 Jenkinsfile
+19 −30 Package.swift
+2 −2 evergreen/config.yml
+11 −0 src/realm.h
+6 −6 src/realm/alloc_slab.cpp
+0 −1 src/realm/cluster_tree.cpp
+1 −2 src/realm/db.cpp
+8 −0 src/realm/object-store/c_api/app.cpp
+3 −1 src/realm/object-store/c_api/error.cpp
+1 −1 src/realm/object-store/sync/impl/sync_file.cpp
+26 −28 src/realm/sync/noinst/server/crypto_server_apple.mm
+1 −1 src/realm/sync/noinst/sync_metadata_schema.cpp
+8 −10 src/realm/sync/tools/apply_to_state_command.cpp
+56 −50 src/realm/transaction.cpp
+21 −68 test/CMakeLists.txt
+9 −12 test/benchmark-common-tasks/main.cpp
+2 −60 test/main.cpp
+17 −28 test/object-store/CMakeLists.txt
+5 −4 test/object-store/backup.cpp
+2 −8 test/object-store/c_api/c_api.cpp
+10 −37 test/object-store/main.cpp
+ test/object-store/sync-1.x.realm
+9 −15 test/object-store/sync/app.cpp
+2 −2 test/object-store/sync/file.cpp
+6 −0 test/object-store/sync/flx_sync.cpp
+3 −2 test/object-store/sync/metadata.cpp
+0 −67 test/object-store/sync/session/session.cpp
+0 −1 test/object-store/sync/session/wait_for_completion.cpp
+0 −2 test/object-store/sync/sync_test_utils.hpp
+ test/resources/cooked_migration/client_schema_version_1.realm
+ test/resources/cooked_migration/server.realm
+8 −5 test/sync_fixtures.hpp
+23 −23 test/test_all.cpp
+2 −2 test/test_crypto.cpp
+2 −1 test/test_noinst_vacuum.cpp
+1 −4 test/test_query.cpp
+30 −66 test/test_sync.cpp
+2 −2 test/test_sync_auth.cpp
+4 −6 test/test_sync_history_migration.cpp
+20 −20 test/test_util_network_ssl.cpp
+88 −31 test/util/test_path.cpp
+3 −21 test/util/test_path.hpp
+15 −29 test/util/unit_test.cpp
+10 −11 test/util/unit_test.hpp
+93 −0 tools/build-apple-device.sh
+4 −23 tools/build-cocoa.sh
+237 −88 tools/cmake/GetGitRevisionDescription.cmake
+3 −1 tools/cmake/GetGitRevisionDescription.cmake.in
+48 −0 tools/cmake/Utilities.cmake
+20 −10 tools/cmake/xcode.toolchain.cmake
+29 −0 tools/run-in-simulator.sh