-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Split Warmer.warm() into smaller functions #1935
Conversation
0983841
to
c92865c
Compare
fe1d18a
to
dcd3fb3
Compare
`Warmer.warming()` was a huge function (~250 loc), making it really hard to read. This change moves most of it into a new `repoCacheManager`, improving readability. After this change `Warmer.warming()` is still 100 loc, but reads much better.
dcd3fb3
to
fefb216
Compare
// updateImages, refreshes the cache entries for the images passed. It may not succeed for all images. | ||
// It returns the values stored in cache, the number of images it succeeded for and the number | ||
// of images whose manifest wasn't found in the registry. | ||
func (c *repoCacheManager) updateImages(ctx context.Context, registryClient registry.Client, images []imageToUpdate) (map[string]image.Info, int, 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.
Just a note; I am not a fan of the .., int, int
return, but wrapping it in a struct to give it more context does not seem very meaningful either, the comment makes up for it a bit though.
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.
Yeah, I am not too pleased with this or fetchImagesResult
either
Happy to look into any suggestions you may have.
Maybe computing the counters outside of the functions? I gave that a short chance but it was hairy. I will give it another try.
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 didn't find a cleaner way. At least not with a much bigger refactoring.
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.
My mind is very pleased with the readability improvement 🌠
Warmer.warming()
was a huge function (~250 loc), making it really hard to read.This change splits the warmer into smaller functions, improving readability.
After this change
Warmer.warming()
is still 100 loc, but reads much better.