Skip to content

Refactor pendingWrites / write pipeline. #1699

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 3 commits into from
Aug 16, 2018
Merged

Conversation

mikelehen
Copy link
Contributor

[Port of https://github.com/firebase/firebase-js-sdk/pull/972]

No functional changes. Just renames, moves, added comments, etc.

  • pendingWrites => writePipeline
  • canWriteMutations renamed canAddToWritePipeline
  • commitBatch => addBatchToWritePipeline
  • lastBatchSeen removed since we can compute it on demand from
    writePipeline.
  • Removed cleanUpWriteStreamState and instead inlined it in
    disableNetworkInternal since I didn't like the non-symmetry with
    cleanUpWatchStreamState which is called every time the stream closes.
  • Misc. comment cleanup.

[Port of firebase/firebase-js-sdk#972]

No functional changes. Just renames, moves, added comments, etc.

* pendingWrites => writePipeline
* canWriteMutations renamed canAddToWritePipeline
* commitBatch => addBatchToWritePipeline
* lastBatchSeen removed since we can compute it on demand from
  writePipeline.
* Removed cleanUpWriteStreamState and instead inlined it in
  disableNetworkInternal since I didn't like the non-symmetry with
  cleanUpWatchStreamState which is called every time the stream closes.
* Misc. comment cleanup.
*
* Whenever writePipeline is not empty the RemoteStore will attempt to start or restart the write
* stream. When the stream is established the writes in the pipeline will be sent in order.
*
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 insert a comma after "is not empty" (line 99) and "stream is established" (line 100).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, but I'm not backporting to the other platforms. 😛

- (BOOL)canWriteMutations {
return [self isNetworkEnabled] && self.pendingWrites.count < kMaxPendingWrites;
- (BOOL)canAddToWritePipeline {
return [self isNetworkEnabled] && self.writePipeline.count < kMaxPendingWrites;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we rename isNetworkEnabled to canUseNetwork like in the other ports?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but that happened in a later PR that I'm not porting (yet).

* Queues additional writes to be sent to the write stream, sending them immediately if the write
* stream is established, else starting the write stream if it is not yet started.
*/
- (void)addBatchToWritePipeline:(FSTMutationBatch *)batch {
Copy link
Contributor

Choose a reason for hiding this comment

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

If I remember the few bits about naming on iOS correctly, then this method name should end in its argument type. I can't come up with any sane suggestions, and since this is a fine C++ name, we may be able to ignore this if you also can't think of a name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I don't see a good way of doing that and we have other similarly-named methods already (e.g. applyChangesToDocuments:(FSTViewDocumentChanges *)docChanges;)

@mikelehen mikelehen merged commit 97c499c into master Aug 16, 2018
@mikelehen mikelehen deleted the mikelehen/stream-tweaks branch August 16, 2018 15:56
@firebase firebase locked and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants