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

Better Subscription lifecycle management #6456

Merged
merged 36 commits into from Mar 21, 2019

Conversation

@cmelchior
Copy link
Contributor

commented Mar 7, 2019

Closes #6453
Closes #2722

This PR adds support for new timestamps which enables better tracking of Subscriptions. It also makes it possible to set a TTL for subscriptions as well as updating the underlying query.

New API's:

// Uses the same naming conventions as copyToRealmOrUpdate or createObjectOrUpdate
RealmQuery.subscribe(String name, long timeToLive, TimeUnit timeUnit);
RealmQuery.subscribeOrUpdate(String name, long timeToLive, TimeUnit timeUnit);
RealmQuery.subscribeOrUpdate(String name);

// These methods use an update boolean since the creation of subscriptions 
// are a side-effect and calling them findAllAsyncOrUpdate feels really awkward. 
// It does make it a little inconsistent though. 
RealmQuery.findAllAsync(String name, boolean update);
RealmQuery.findAllAsync(String name, long timeToLive, TimeUnit timeUnit);
RealmQuery.findAllAsync(String name, long timeToLive, TimeUnit timeUnit, boolean update);

TODO

  • Finalize OS PR and direct to master. Will need a few adjustments when this is happening.
  • Add findAllAsync() API's + tests
  • Add RealmQuery.subscribe() API's + tests
  • Extend Subscription + tests
  • Document new API's on website

@cmelchior cmelchior self-assigned this Mar 7, 2019

@cmelchior cmelchior requested review from kneth and nhachicha and removed request for kneth Mar 11, 2019

@cmelchior cmelchior marked this pull request as ready for review Mar 11, 2019

@cmelchior cmelchior requested a review from kneth Mar 11, 2019

@cmelchior

This comment has been minimized.

Copy link
Contributor Author

commented Mar 11, 2019

Ready for review

@kneth

kneth approved these changes Mar 11, 2019

CHANGELOG.md Outdated Show resolved Hide resolved
@bmunkholm

This comment has been minimized.

Copy link
Contributor

commented Mar 11, 2019

Let's ensure we design this API for other SDKs before this is released to ensure consistency in API and naming as needed.

@cmelchior

This comment has been minimized.

Copy link
Contributor Author

commented Mar 11, 2019

All methods are marked @Beta for that reason, but yes, we might as well get the worst API kinks out of the way before releasing it.

kneth and others added some commits Mar 11, 2019

Update CHANGELOG.md
Co-Authored-By: cmelchior <christian@ilios.dk>
Update realm/realm-library/src/main/java/io/realm/RealmQuery.java
Co-Authored-By: cmelchior <christian@ilios.dk>
Update realm/realm-library/src/main/java/io/realm/RealmQuery.java
Co-Authored-By: cmelchior <christian@ilios.dk>
Update realm/realm-library/src/main/java/io/realm/RealmQuery.java
Co-Authored-By: cmelchior <christian@ilios.dk>
Update realm/realm-library/src/androidTest/java/io/realm/internal/JNI…
…NativeTest.java

Co-Authored-By: cmelchior <christian@ilios.dk>
Update realm/realm-library/src/main/java/io/realm/RealmQuery.java
Co-Authored-By: cmelchior <christian@ilios.dk>
Update realm/realm-library/src/main/java/io/realm/RealmQuery.java
Co-Authored-By: cmelchior <christian@ilios.dk>
Update realm/realm-library/src/main/java/io/realm/RealmQuery.java
Co-Authored-By: cmelchior <christian@ilios.dk>

kneth and others added some commits Mar 11, 2019

Update realm/realm-library/src/main/java/io/realm/RealmQuery.java
Co-Authored-By: cmelchior <christian@ilios.dk>
Update realm/realm-library/src/main/java/io/realm/RealmQuery.java
Co-Authored-By: cmelchior <christian@ilios.dk>
Update realm/realm-library/src/main/java/io/realm/RealmQuery.java
Co-Authored-By: cmelchior <christian@ilios.dk>
Update realm/realm-library/src/main/java/io/realm/RealmQuery.java
Co-Authored-By: cmelchior <christian@ilios.dk>
CHANGELOG.md Outdated Show resolved Hide resolved
## 5.10.0(YYYY-MM-DD)

## Enhancements
* [ObjectServer] Added 4 new fields to query-based Subscriptions: `createdAt`, `updatedAt`, `expiresAt` and `timeToLive`. These make it possible to better reason about and control current subscriptions. (Issue [#6453](https://github.com/realm/realm-java/issues/6453))

This comment has been minimized.

Copy link
@bmunkholm

bmunkholm Mar 12, 2019

Contributor

Are these to be actively used by end-users? Then describe how. If not, move to internal.

This comment has been minimized.

Copy link
@cmelchior

cmelchior Mar 12, 2019

Author Contributor

It is just meta data fields like the current name which are accessed through standard getters. I don't think it make sense to describe it in more detail as that would be very application specific how you would want to use them.

This comment has been minimized.

Copy link
@bmunkholm

bmunkholm Mar 12, 2019

Contributor

Will they be mentioned in our docs?

This comment has been minimized.

Copy link
@cmelchior

cmelchior Mar 12, 2019

Author Contributor

Yes

bmunkholm and others added some commits Mar 12, 2019

Update CHANGELOG.md
Co-Authored-By: cmelchior <christian@ilios.dk>

@cmelchior cmelchior added this to the 2019-w12 milestone Mar 19, 2019

cmelchior added some commits Mar 20, 2019

@cmelchior cmelchior requested a review from kneth Mar 21, 2019

@kneth

kneth approved these changes Mar 21, 2019

* [ObjectServer] Added the option of setting a time-to-live for subscriptions. Setting this will automatically delete the subscription after the provided TTL has expired and the subscription hasn't been used. (Issue [#6453](https://github.com/realm/realm-java/issues/6453))

## Fixed
* Dates returned from the Realm file no longer overflow or underflow if they exceed `Long.MAX_VALUE` or `Long.MIN_VALUE` but instead clamp to their respective value. (Issue [#2722](https://github.com/realm/realm-java/issues/2722))

This comment has been minimized.

Copy link
@kneth

kneth Mar 21, 2019

Contributor

❤️

CHANGELOG.md Outdated Show resolved Hide resolved

kneth and others added some commits Mar 21, 2019

Update CHANGELOG.md
Co-Authored-By: cmelchior <christian@ilios.dk>
Update realm/realm-library/src/main/java/io/realm/sync/Subscription.java
Co-Authored-By: cmelchior <christian@ilios.dk>
@nhachicha
Copy link
Contributor

left a comment

Looks good 👏

@cmelchior cmelchior merged commit 40bd574 into master Mar 21, 2019

1 check passed

continuous-integration/jenkins/pr-head This commit looks good
Details

@cmelchior cmelchior deleted the cm/subscription-timestamps branch Mar 21, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.