-
Notifications
You must be signed in to change notification settings - Fork 15
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
refactor: Extract store package #100
Conversation
Now that this only loads documents within a single collection, we can push the collection name into the get function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
I have some style thoughts for a future cleanup:
- Early-bind the
firestoreClient
, so we don't have to deal withpl.db
in every call - Some places with arguments
recurser.ID, recurser
-- seems like a redundant argument?
Maybe I'll just send the PR :)
Er, I guess this is what we're getting away from: having four different objects in the top-level. Hm. |
Yeah, I go back-and-forth on this one a lot. My motivation for doing it in this PR was to make the "constructor" for I don't mind the struct itself having all four of them early-bound, though! I just don't like
Agreed! There's even one place I know that the first arg is (now) even totally unused: pairing-bot/store/recursers.go Line 114 in 235495c
Yes, please! Or if not, we can offer it as a "good first issue" for someone who wants to get started learning Go. Either way makes me happy! :) |
Now that we've cleaned up
database.go
a bit, it looks like a good candidate for extraction into its own package. This makes it easier to test and explain to new contributors.I named the package
store
becausefirestore
would have collided with the actual Firestore client package andfs
would have collided with the actual standard library filesystem package. We can re-refactor into a better name if we find one!Some extra changes I made along the way:
FirestoreFooDB
tostore.FooClient
pbtest
package now that the test Firestore client is used in two test packages.assert.Equal
helper instead of defining.Equal
methods on DB structs.