Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
client: Improve testing and increase coverage #636
client: Improve testing and increase coverage #636
Changes from all commits
56b1f15
1a3a6e5
e3cc3b8
ce6872c
92b9745
ae384ed
d109f2d
ee40390
93b61f8
b75db12
e94cd49
0de224e
756cd3f
4269131
614a5a7
195a8f2
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Likely you can just
defer c.sendStatistic(...)()
and handlestatisticCallback
andstartTime
internally.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.
if
if
is inevitable, then it is better to make a conditionaldefer
imoThere 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.
but why? you turned out the func that is commonly used and made more lines, no? i think it was planned as
defer c.sendStatistic(...)()
but smth went wrong, why make things harder?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.
Not doing a
defer
is obviously more efficient, but for these (network) operations the difference is so negligible that I'd rather opt for simpler code.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've done this not just for negligible optimization but for more clear code. Previously, i saw unconditional deferred stats, making me think that some stats are always tracked while
sendStatistics
encapsulates the logic that there can be no stats at all! Also, seeingdefer func() { c.method()() }()
blows my mind, i definitely cannot agree this is a simpler codefinally, if no one has any categorical objections, i'd leave the fixed version
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.
mine is many repetitive lines for every method. also, you still use
defer
so why not, at least i would try to inline time calculation:time.Since(time.Now())
agree but once you get it you just see in every method, it is our general approach
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.
hm, how would it be?
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 meant start time can be an arg of the deferred func, provided wrong example
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.
done
Check warning on line 82 in client/accounting.go
client/accounting.go#L81-L82