Skip to content

Expose operation counts from Persistence layer (take 2) #2165

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

Conversation

schmidt-sebastian
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian commented Sep 10, 2019

"Sebastian uses his time wisely."

This is another take on #2164.

It solves the following issues:

  • It doesn't add any stats that are not used/not tested.
  • It doesn't add code to the main client.
  • It removes the need to plumb a counter through the Persistence layer.
  • it reduces the reliance on the exact implementation, but instead focuses more on the result of each operation.
  • it gives us a reason to port this back to Android.

@schmidt-sebastian schmidt-sebastian force-pushed the mrschmidt/indexfree-counter2 branch from f023559 to eea6982 Compare September 10, 2019 00:42
@schmidt-sebastian
Copy link
Contributor Author

Note that I did experiment with https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy, but was never able to get it to work via TS Node. It would also require us to use a different tsconfig for the unit tests (to add a dependency on es2015.proxy).

@schmidt-sebastian
Copy link
Contributor Author

"Coverage decreased (-0.05%) to 89.621%"

I don't believe you.

@schmidt-sebastian schmidt-sebastian force-pushed the mrschmidt/indexfree-counter2 branch from 0005f4a to 6966e26 Compare September 10, 2019 04:17
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.

I like this better. I'm not 100% sure on the cost-benefit ratio given this is still 270 lines of code and it's going to be fragile in the face of any changes to the RemoteDocumentCache, MutationQueue, or QueryEngine interfaces. But it's well isolated so if it ends up being more trouble than it's worth, it'll be easy to rework. So in that respect, I like it a lot. 😄

private indexManager: IndexManager
readonly remoteDocumentCache: RemoteDocumentCache,
readonly mutationQueue: MutationQueue,
readonly indexManager: IndexManager
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm guessing this is why coverage decreased. Making these readonly probably costs us a few bytes. 😄

* A test-only query engine that forwards all API calls and exposes the number
* of documents and mutations read.
*/
export class ForwardingCountingQueryEngine implements QueryEngine {
Copy link
Contributor

Choose a reason for hiding this comment

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

ForwardingCountingQueryEngine doesn't read super nicely. I think I would do OpCountingQueryEngine or OpCountingQueryEngineWrapper or something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I dropped the "Forwarding" part. Not sold on your suggestions :)

}

private wrapRemoteDocumentCache(
target: RemoteDocumentCache
Copy link
Contributor

Choose a reason for hiding this comment

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

"target" is already used for something else in the client. Find a new term. 😄 E.g.: remoteDocumentCache, internal, wrapped

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used "source" (which is also used, but much more lightly...)

@schmidt-sebastian
Copy link
Contributor Author

Merging this since the pervious CI run passed and changes are just renames/minor.

@schmidt-sebastian schmidt-sebastian merged commit 55ffe46 into mrschmidt/indexfree-master Sep 10, 2019
@schmidt-sebastian schmidt-sebastian deleted the mrschmidt/indexfree-counter2 branch October 10, 2019 22:55
@firebase firebase locked and limited conversation to collaborators Oct 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants