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

Add support for flexible subscriptions #496

Merged
merged 49 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
4d2962e
Introduce hierarchy on Configurations
nielsenko Apr 20, 2022
9dc0956
Deprecate the inMemory field. Replaced with InMemoryConfiguration
nielsenko Apr 22, 2022
604e713
Support for flexible sync configuration
nielsenko Apr 22, 2022
03c2a39
Add SubscriptionSet (and MutableSubscriptionSet)
nielsenko Apr 25, 2022
1d8743c
Add SubscriptionSet.waitForStateChangeSync.
nielsenko Apr 26, 2022
a349fea
Align with kotlin naming
nielsenko Apr 26, 2022
7008377
Support session stop policy
nielsenko Apr 26, 2022
295f051
Support async SubscriptionSet.waitForStateChange
nielsenko Apr 28, 2022
7b859e5
Make subscription non-nullable. Throw, if configuration not a Flexibl…
nielsenko May 2, 2022
5a135a6
Add version & state properties to SubscriptionSet
nielsenko May 2, 2022
9e4b3da
Annoying hack
nielsenko May 2, 2022
4d2da95
Fix SubscriptionSet.find* when nothing found
nielsenko May 2, 2022
a976fea
More tests
nielsenko May 2, 2022
efffee0
Add elementAt test
nielsenko May 2, 2022
0e2da68
Fix windows build
fealebenpae May 2, 2022
e035788
Add subscription tests to flutter tests
nielsenko May 5, 2022
f869a9e
Update core to c9c9f5e62 (v11.15.0-8-gc9c9f5e62)
nielsenko May 5, 2022
3028bf0
Use C-API in realm_dart_sync_on_subscription_set_state_change_async
nielsenko May 5, 2022
0ca0779
Prevent downcast of Realm.subscriptions to MutableSubscriptionSet
nielsenko May 5, 2022
0c3bdce
Remove lifetime hack
nielsenko May 5, 2022
956d78c
Fix PR feedback
nielsenko May 9, 2022
1963b08
Rename addOrUpdate to add and return subscription
nielsenko May 9, 2022
83ed6f1
Reorder and enhance doc comments
nielsenko May 9, 2022
722f000
Rework SubscriptionSet.remove*
nielsenko May 10, 2022
e391f59
More PR feedback
nielsenko May 10, 2022
1c190c1
Update core to dc15bdc (v11.15.0-16-gdc15bdc36)
nielsenko May 5, 2022
2f9843a
Wire up properties on Subscription
nielsenko May 6, 2022
3e351b5
Add Subscription properties test
nielsenko May 6, 2022
b485a29
Fix PR feedback
nielsenko May 10, 2022
81ba0f6
Update core to 8c2ad6f (v11.15.0-24-g8c2ad6fc8)
nielsenko May 11, 2022
e6e469e
Avoid storing _queryHandle on RealmResult
nielsenko May 11, 2022
d98ab3a
Added sync roundtrip test
nielsenko May 11, 2022
9bd11fd
Hide SubscriptionSetState uncommitted and bootstrapping from users
nielsenko May 11, 2022
0fa5d04
Tweak Subscription.operator== to use .id (workaround for capi issue)
nielsenko May 11, 2022
52b1962
Test subscriptions with same name, but different classes throws
nielsenko May 11, 2022
5adf8db
Test adding subscriptions with same name, different classes, with upd…
nielsenko May 11, 2022
55fe548
Test adding subscriptions with same query, different classes
nielsenko May 11, 2022
fe38805
Test SubscriptionSet.find return match, even if named
nielsenko May 11, 2022
b47d87c
Test MutableSubscriptionSet.remove same query, different classes
nielsenko May 11, 2022
a90303d
Augment elementAt tests, and throw proper RangeError on out-of-bounds
nielsenko May 11, 2022
959e619
Test MutableSubscriptionSet.add illegal query
nielsenko May 11, 2022
0e59769
Add some missing docs
nielsenko May 12, 2022
78fecfe
A different way..
nielsenko May 16, 2022
8a4a758
Simplify some allocation calls: `arena.allocate<Uint8>(1)` become `ar…
nielsenko May 16, 2022
6e6ac2a
Don't deprecate Configuration ctor, remove immediately
nielsenko May 16, 2022
6d61652
Outcome of PR review
nielsenko May 16, 2022
e9ced16
Change factories on Configuration to static methods
nielsenko May 16, 2022
734b3d1
Update realm-core to v11.16.0 (#572)
nielsenko May 17, 2022
48c8ab7
Fix a doc comment
nielsenko May 17, 2022
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Breaking Changes
* Made all `Configuration` fields final so they can only be initialized in the constructor. This better conveys the immutability of the configuration class. ([#455](https://github.com/realm/realm-dart/pull/455))
* Removed `inMemory` field from `Configuration`. Use `Configuration.inMemory` factory instead.
* Due to the introduction of different types of configurations the `Configuration` constructor has been removed. Use the `Configuration.local` factory instead. ([#496](https://github.com/realm/realm-dart/pull/496))

### Enhancements
* Added a property `Configuration.disableFormatUpgrade`. When set to `true`, opening a Realm with an older file format will throw an exception to avoid automatically upgrading it. ([#310](https://github.com/realm/realm-dart/pull/310))
Expand Down Expand Up @@ -35,6 +37,7 @@
* Support user deviceId. ([#570](https://github.com/realm/realm-dart/pull/570))
* Support user authentication provider type. ([#570](https://github.com/realm/realm-dart/pull/570))
* Support user profile data. ([#570](https://github.com/realm/realm-dart/pull/570))
* Support flexible synchronization. ([#496](https://github.com/realm/realm-dart/pull/496))

### Fixed
* Fixed an issue that would result in the wrong transaction being rolled back if you start a write transaction inside a write transaction. ([#442](https://github.com/realm/realm-dart/issues/442))
Expand Down
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

# Needed for Win32 headers we might pull in
if(CMAKE_SYSTEM_NAME MATCHES "^Windows")
add_compile_definitions(
WIN32_LEAN_AND_MEAN # include minimal Windows.h for faster builds
UNICODE # prefer Unicode variants of Windows APIs over ANSI variants
_UNICODE # prefer Unicode variants of C runtime APIs over ANSI variants
)
endif()

set(_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING=1)

add_subdirectory(src)
5 changes: 4 additions & 1 deletion dartdoc_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ dartdoc:
"Application":
markdown: topic.md
name: Application
categoryOrder: ["Realm", "Configuration", "Annotations", "Application"]
"Sync":
markdown: topic.md
name: Sync
categoryOrder: ["Realm", "Configuration", "Annotations", "Application", "Sync"]
examplePathPrefix: 'example'
# nodoc: ['generator/flutter/ffigen/scripts/src/test/*.g.dart']
showUndocumentedCategories: true
Expand Down
2 changes: 2 additions & 0 deletions ffigen/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ headers:
- 'realm_dart.h'
- 'realm_dart_scheduler.h'
- 'realm_android_platform.h'
- 'subscription_set.h'
include-directives: #generate only for these headers
- 'realm.h'
- 'realm_dart.h'
- 'realm_dart_scheduler.h'
- 'realm_android_platform.h'
- 'subscription_set.h'
compiler-opts:
- '-DRLM_NO_ANON_UNIONS'
- '-DFFI_GEN'
Expand Down
1 change: 1 addition & 0 deletions ffigen/subscription_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
<true/>
<key>com.apple.security.network.server</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>
2 changes: 2 additions & 0 deletions flutter/realm_flutter/tests/test_driver/realm_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import '../test/results_test.dart' as results_tests;
import '../test/credentials_test.dart' as credentials_tests;
import '../test/app_test.dart' as app_tests;
import '../test/user_test.dart' as user_tests;
import '../test/subscription_test.dart' as subscription_test;

Future<String> main(List<String> args) async {
final Completer<String> completer = Completer<String>();
Expand All @@ -27,6 +28,7 @@ Future<String> main(List<String> args) async {
await credentials_tests.main(args);
await app_tests.main(args);
await user_tests.main(args);
await subscription_test.main(args);

tearDown(() {
if (Invoker.current?.liveTest.state.result == test_api.Result.error || Invoker.current?.liveTest.state.result == test_api.Result.failure) {
Expand Down
31 changes: 15 additions & 16 deletions lib/src/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,9 @@ import 'credentials.dart';
import 'user.dart';
import 'configuration.dart';

/// Specify if and how to persists user objects.
/// {@category Application}
enum MetadataPersistenceMode {
/// Persist [User] objects, but do not encrypt them.
plaintext,

/// Persist [User] objects in an encrypted store.
encrypted,

/// Do not persist [User] objects.
disabled,
}

@immutable

/// A class exposing configuration options for an [App]
/// {@category Application}
@immutable
class AppConfiguration {
/// The [appId] is the unique id that identifies the Realm application.
final String appId;
Expand Down Expand Up @@ -144,7 +130,7 @@ class App {
Future<void> removeUser(User user) async {
return await realmCore.removeUser(this, user);
}

/// Switches the [currentUser] to the one specified in [user].
void switchUser(User user) {
realmCore.switchUser(this, user);
Expand All @@ -154,6 +140,19 @@ class App {
EmailPasswordAuthProvider get emailPasswordAuthProvider => EmailPasswordAuthProviderInternal.create(this);
}

/// Specify if and how to persists user objects.
/// {@category Application}
enum MetadataPersistenceMode {
/// Persist [User] objects, but do not encrypt them.
plaintext,

/// Persist [User] objects in an encrypted store.
encrypted,

/// Do not persist [User] objects.
disabled,
}

/// @nodoc
extension AppInternal on App {
AppHandle get handle => _handle;
Expand Down
Loading