Skip to content

Convert GetOptions to Source #826

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

Merged
merged 4 commits into from
Feb 27, 2018

Conversation

rsgowman
Copy link
Member

Reworks the existing options object into a source parameter.

Reworks the existing options object into a source parameter.
@rsgowman rsgowman self-assigned this Feb 21, 2018
@rsgowman rsgowman requested a review from mikelehen February 21, 2018 17:20
@rsgowman
Copy link
Member Author

@mikelehen : Make sure this makes sense wrt your optionsoptions proposal. Thanks.

Copy link
Contributor

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

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

Basically LGTM but a few questions / nits.


/**
* An enum that configures the behavior of `DocumentReference.getDocument()`
* and `CollectionReference.getDocuments()`. By providing a source enum the
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably be Query.getDocuments() ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

* server, only from the local cache, or attempt the server and fall back to
* the cache (which is the default).
*
* Setting the source to FIRSourceDefault, if online, causes Firestore to try
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we're using Swift syntax above, this should perhaps be Source.default ? [in general we're really inconsistent about Swift vs Obj-C in our comments, but we may as well be consistent within a single comment block. :-)]

Copy link
Member Author

Choose a reason for hiding this comment

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

Consistency? Hmm... well I suppose we could try that. Done.

*
* FIRSourceServer causes Firestore to avoid the cache (generating an error if
* a value cannot be retrieved from the server). The cache will be updated if
* the RPC succeeds. Latency compensation still occurs (implying that if the
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd avoid reference "the RPC" since that's dropping to a lower abstraction layer. Perhaps just "The cache will be updated with the data retrieved from the server."

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

* FIRSourceServer causes Firestore to avoid the cache (generating an error if
* a value cannot be retrieved from the server). The cache will be updated if
* the RPC succeeds. Latency compensation still occurs (implying that if the
* cache is more up to date, then it's values will be merged into the results).
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say something like "(that is, any local pending writes will be visible in the results)" as "is more up to date" isn't quite accurate. FWIW I think I've commented on this verbiage somewhere else (the JS PR?) and I'd try to keep them in sync so you may want to look at that as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

The JS one is certainly out-of-date, so I'll consider this one the "master" and will update the js one to match.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please still do a scan over the feedback on the JS one to see if anything should be applied to this PR...

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I see what you mean. Backported.

*
* FIRSourceCache causes Firestore to immediately return a value from the
* cache, ignoring the server completely (implying that the returned value may
* be stale with respect to the value on the server.) For a single document,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Period should be outside the paren. :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

(Done.)

* FIRSourceCache causes Firestore to immediately return a value from the
* cache, ignoring the server completely (implying that the returned value may
* be stale with respect to the value on the server.) For a single document,
* the get will fail if the document doesn't exist.
Copy link
Contributor

Choose a reason for hiding this comment

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

"doesn't exist" should be "isn't in the cache" or similar, since we don't know if it exists.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

* be stale with respect to the value on the server.) For a single document,
* the get will fail if the document doesn't exist.
*/
typedef NS_ENUM(NSUInteger, FIRSource) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we explicitly decide to change from FIRGetSource to FIRSource? I may be forgetting a discussion, but I think I'd be inclined to keep it as FIRGetSource (less likely to conflict with other Firebase naming in the future, and since you can omit it in Swift it doesn't affect usability).

Copy link
Member Author

Choose a reason for hiding this comment

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

For objc? I don't think we did. I "back-ported" the Source from swift to FIRSource. I've changed it to FIRGetSource (and left swift as Source.)

Copy link
Contributor

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

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

LGTM. Do you mind adding an entry to CHANGELOG.md too? We (especially I) always forget to do that which leads to things getting missed in our release notes. :-/

@rsgowman
Copy link
Member Author

Update changelog.

Copy link
Contributor

@wilhuff wilhuff left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

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

Thanks for the additional doc updates!

@rsgowman rsgowman merged commit 607fe11 into firestore-api-changes Feb 27, 2018
@rsgowman rsgowman deleted the rsgowman/getoptions_optionsoptions branch February 27, 2018 15:12
@firebase firebase locked and limited conversation to collaborators Nov 7, 2019
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.

4 participants