-
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
Support LATENCY LATEST, LATEST HISTORY command parsing #614
Support LATENCY LATEST, LATEST HISTORY command parsing #614
Conversation
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.
Thanks for the PR, there's a few things I've noted below.
While I think this could be helpful I'm wondering how much use it would get and hence should we put these type of helpers in their own sub package to avoid polluting the main API?
Something like:
redis/latency
which would provide calls like:
latency.Latest(result interface{}, err error) ([]LatestEvent, error)
latency.History(result interface{}, err error) ([]HistoryEvent, error)
Thoughts?
Thank you @stevenh, a lot of valuable suggestions and learning here! I'll aim to go through it over next couple of days. I'll aim to apply the same changes to SlowLogs helper/tests which I've based my change on. |
I would encourage you do the changes to SlowLogs in a different PR, to avoid confusing issues. |
When developing a tool to logout latency.Latest(result interface{}, err error) ([]LatestEvent, error)
latency.History(result interface{}, err error) ([]HistoryEvent, error) |
Update golangci-lint to a version compatible with golang 1.18.
I've applied suggested changes in all the instances that I could find. Tests look a lot more dense and readable. Not sure what is more usable:
or
Framework does point at the problematic test, but lacking of particular details outside of the error message:
Additionally, I've renamed |
My take on is that in 99% of cases you get all the context needed from the test name If you added the message Adding The way I look at it is use a message where it helps the developer understand why this check exists if it's not clear, which for almost all cases is already obvious particularly so for Another thing in that snippet is the variable naming As a full example I would go for the following in this particualar case: res, err := redis.Strings(c.Do("CONFIG", "GET", "latency-monitor-threshold"))
require.NoError(t, err)
if len(res) == 0 {
t.Skip("Latency commands not supported, added in redis 2.8.13")
} Hope that helps. |
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.
Making some great progress, here's some more pointers.
Personally I would remove all the require
messages as per my reply to your question.
If you compare with and without, you'll see the code is much less busy which improves readability, without removing any understanding for a developer looking at any potential failure based.
@stevenh , thank you for the time invested into this. I've learned a lot already and made another iteration incorporating your feedback. Let me know if there is anything else I can improve upon. Thanks |
Thanks @dmitri-lerko if you could mark all the comments you have addressed at resolved, that will make it easier to do another review :) |
Hi @stevenh, I've resolved all but one comments. Please let me know what you think. Thanks |
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.
Just some error message and comments to clean up and should be good to go.
Co-authored-by: Steven Hartland <[email protected]>
Thanks for PR @dmitri-lerko much appreciated. |
Hi @stevenh , thank you for your time on this PR. I'll aim to bring slowlog in light with the changes above to have better consistency. |
Includes tests similar to how SlowLog was tested.