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
fileutil: improve control flow readability of purgeFile function #17564
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: redwrasse <mail@redwrasse.io>
Hi @redwrasse. Thanks for your PR. I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
client/pkg/fileutil/purge.go
Outdated
@@ -53,26 +52,35 @@ func purgeFile(lg *zap.Logger, dirname string, suffix string, max uint, interval | |||
zap.Uint("max", max), | |||
zap.Duration("interval", interval)) | |||
|
|||
readDirWithSuffix := func(dirname string) ([]string, 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.
Why not have it as normal function (defined outside of other functions body) instead of anonymous 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.
No need to have an anonymous function, agreed. Do you suggest adding as a separate function in purge.go
?
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.
converted to a normal function in purge.go
. this is a little awkward though as it should properly probably be part of read_dir.go
.
Signed-off-by: redwrasse <mail@redwrasse.io>
c35aecb
to
6cf5419
Compare
/retest |
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.
LGTM
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.
LGTM
cc @serathius |
PR for issue #17565
Proposed improvement to syntax for control flow of
purgeFile
function inclient/pkg/fileutil/purge.go
.fnamesWithSufix
that remains unmodified.nPurged
variable introduced for for loop in go routine, and for counting writes topurgeC
channel.ReadDir
method reads directory filenames in sorted order, and sorted order is preserved after suffix filtering.