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 new subscribe API #3403

Merged
merged 5 commits into from
Aug 2, 2023
Merged

Add new subscribe API #3403

merged 5 commits into from
Aug 2, 2023

Conversation

nirinchev
Copy link
Member

@nirinchev nirinchev commented Jul 31, 2023

Description

Fixes RNET-865

Adds IQueryable.SubscribeAsync syntax sugar.
Adds cancellationToken argument to Session.WaitForDownloadAsync, Session.WaitForUploadAsync, and SubscriptionSet.WaitForSynchronization. This doesn't cancel the underlying Core wait operation, just the managed task. While it's not ideal, the native wait operation is not really expensive and it will eventually complete anyway, so we are not leaking resources.

There are some whitespace changes, so it might be a good idea to review with the "Ignore whitespace" option.

TODO

  • Changelog entry
  • Tests (if applicable)

@coveralls
Copy link

coveralls commented Jul 31, 2023

Pull Request Test Coverage Report for Build 5736508132

  • 118 of 127 (92.91%) changed or added relevant lines in 6 files are covered.
  • 2 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.01%) to 82.489%

Changes Missing Coverage Covered Lines Changed/Added Lines %
Realm/Realm/Handles/SessionHandle.cs 8 10 80.0%
Realm/Realm/Extensions/CollectionExtensions.cs 91 94 96.81%
Realm/Realm/Handles/SubscriptionSetHandle.cs 13 17 76.47%
Files with Coverage Reduction New Missed Lines %
Realm/Realm/Handles/SessionHandle.cs 1 84.65%
Realm/Realm/Handles/SubscriptionSetHandle.cs 1 93.02%
Totals Coverage Status
Change from base Build 5725064786: 0.01%
Covered Lines: 6279
Relevant Lines: 7472

💛 - Coveralls

@nirinchev nirinchev marked this pull request as ready for review August 1, 2023 06:11
Copy link
Contributor

@papafe papafe left a comment

Choose a reason for hiding this comment

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

Looks good.
By the way, it was a little bit difficult to see the body of SubscribeAsync together with the removal of the namespace block 😁

@@ -1,11 +1,23 @@
## vNext (TBD)

### Enhancements
* None
* Added `IQueryable.SubscribeAsync` API as a shorthand for using `SubscriptionSet.Add`. It is a syntax sugar that roughly translates to:
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add the equivalent code that uses SubscribeAsync, so it's a little bit clearer

Tests/Realm.Tests/Database/APITests.cs Outdated Show resolved Hide resolved
{
var tcs = new TaskCompletionSource();
if (cancellationToken?.IsCancellationRequested == true)
{
tcs.TrySetCanceled(cancellationToken.Value);
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure I understand why we need this and the following line. Can we just return?

Copy link
Member Author

Choose a reason for hiding this comment

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

If cancellation is requested, the expected behavior would be to throw a TaskCancelledException, even if we didn't start doing the work. Regarding why we're cancelling the tcs vs throwing a TaskCancelledException, I guess both are roughly the same and don't have strong feelings about one or the other.

@nirinchev
Copy link
Member Author

By the way, it was a little bit difficult to see the body of SubscribeAsync together with the removal of the namespace block

That's why you're supposed to read the PR description 😜

@nirinchev nirinchev merged commit add75b7 into main Aug 2, 2023
63 checks passed
@nirinchev nirinchev deleted the ni/subscribe-api branch August 2, 2023 09:02
papafe added a commit that referenced this pull request Aug 2, 2023
* main:
  Add new subscribe API (#3403)
  Update QuickJournal (#3401)
  Add a few tests for uncovered code (#3405)
  Update to Core 13.17.1 (#3404)
  Use modern-er marshaling techniques (#3261)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants