-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Restructure database folder #721
Conversation
KeyboardNerd
commented
Feb 27, 2019
•
edited
Loading
edited
- one pgsql data model per folder, and one table per file
- one data model per file
d3a1e55
to
207646e
Compare
1fe0831
to
f9494d7
Compare
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.
I tried not to nitpick existing code.
// features and processors used to scan the ancestry. | ||
func (tx *pgSession) UpsertAncestry(a database.Ancestry) error { | ||
return ancestry.UpsertAncestry(tx.Tx, a) | ||
} |
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.
Since these are all basically doing the same thing, I'll often keep the entire thing on one line and stack them all up.
func (tx *pgSession) UpsertAncestry(a database.Ancestry) error { return ancestry.UpsertAncestry(tx.Tx, a) }
func (tx *pgSession) FindAncestry(name string) (database.Ancestry, bool, error) { return ancestry.FindAncestry(tx.Tx, name) }
func (tx *pgSession) PersistDetectors(detectors []database.Detector) error { return detector.PersistDetectors(tx.Tx, detectors) }
func (tx *pgSession) PersistFeatures(features []database.Feature) error { return feature.PersistFeatures(tx.Tx, features) }
func (tx *pgSession) PersistNamespacedFeatures(features []database.NamespacedFeature) error { return feature.PersistNamespacedFeatures(tx.Tx, features) }
func (tx *pgSession) CacheAffectedNamespacedFeatures(features []database.NamespacedFeature) error { return vulnerability.CacheAffectedNamespacedFeatures(tx.Tx, features) }
func (tx *pgSession) FindAffectedNamespacedFeatures(features []database.NamespacedFeature) ([]database.NullableAffectedNamespacedFeature, error) { return vulnerability.FindAffectedNamespacedFeatures(tx.Tx, features) }
func (tx *pgSession) PersistNamespaces(namespaces []database.Namespace) error { return namespace.PersistNamespaces(tx.Tx, namespaces) }
...
It makes it clear that there isn't really logic going on here, and that everything is boilerplate.
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.
gofmt doesn't like that idea
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.
dang, sometimes it does, not sure what the rule is: https://github.com/chihaya/chihaya/blob/master/storage/redis/peer_store_test.go#L35
rebased to master, hope no issues because of merge conflict |
- assertion.go assertions used in pgsql tests - data.go contains go representation of data.sql - testdb.go contains test db/tx creation logic - testutil.go contains misc other things
- pgsql/util/error.go contains error handling logic - pgsql/page/page.go contains the page struct - pgsql/monitoring contains the prometheus logic - pgsql/pgsession contains the pgsession struct
- Tests in complex_test.go are now in corresponding test files. - Pgsql_test is partially moved to testutil/testdb.go