-
Notifications
You must be signed in to change notification settings - Fork 38
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
metabase: drop almost all of Prm/Res structures #3001
Conversation
They: * are present in some methods and not in others * add substantial cognitive overhead for anyone looking * require more code to handle trivial things * can allocate more and more of microobjects creating GC pressure Test wrappers in the same package perfectly suggest what everyone wanted to have in the first place. So this patch is a pure refactoring and doesn't change any behavior, but it drops almost all structures. "Almost" because there are cases where we pass a number of things (mostly as a result) and having some enclosing structure makes some sense there. Signed-off-by: Roman Khimov <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3001 +/- ##
==========================================
- Coverage 23.15% 23.05% -0.11%
==========================================
Files 789 789
Lines 58815 58669 -146
==========================================
- Hits 13619 13526 -93
+ Misses 44312 44262 -50
+ Partials 884 881 -3 ☔ View full report in Codecov by Sentry. |
prm.SetCount(vLimit) | ||
|
||
res, err := db.ListWithCursor(prm) | ||
addrs, _, err := db.ListWithCursor(int(vLimit), nil) |
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.
why int?
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.
Because that's the type ListPrm
had for count
.
// Does not stop on an error if there are more objects to handle requested; | ||
// returns the first error appeared with a number of deleted objects wrapped. | ||
func (db *DB) Delete(prm DeletePrm) (DeleteRes, error) { | ||
func (db *DB) Delete(addrs []oid.Address) (DeleteRes, error) { |
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.
it was variadic. not sure api has become better. but also does not claim it as a much worse one
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.
From what I see real users have arrays anyway, so this works fine.
} | ||
|
||
// DoNotMove removes `MoveIt` mark from the object. | ||
func (db *DB) DoNotMove(prm DoNotMovePrm) (res DoNotMoveRes, err error) { |
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.
wow, i had no idea we had this method
Mostly similar to #3001, we have a number of Prm/Res structures that make it harder to used engine and trace things going on. But there are some functional changes here as well and also things that go beyond Prm/Res. Overall we get rid of many pointless conversions.
They:
Test wrappers in the same package perfectly suggest what everyone wanted to have in the first place. So this patch is a pure refactoring and doesn't change any behavior, but it drops almost all structures. "Almost" because there are cases where we pass a number of things (mostly as a result) and having some enclosing structure makes some sense there.