-
Notifications
You must be signed in to change notification settings - Fork 511
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
cache: add SetSnapshot and GetSnapshot to LinearCache #437
cache: add SetSnapshot and GetSnapshot to LinearCache #437
Conversation
Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
Sorry about the force push 🙏 I started the work from |
Thanks for opening this! I'll review |
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 few things so far
Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
hey, @alecholmez do you have any more suggestions? |
@jakubdyszkiewicz I think this is good from my end, can you address the merge conflicts? @snowp you have any thoughts? |
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 this looks good to me for the most part, just a few minor nits
cache.version += 1 | ||
|
||
modified := map[string]struct{}{} | ||
for name := range cache.resources { |
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.
Some comments would be make this easier to follow, like // First account for removed resources.
and a similar one for the other for loop
pkg/cache/v3/linear.go
Outdated
cache.resources = resources | ||
for name := range resources { | ||
// We assume all resources passed to SetResources are changed. | ||
// Otherwise we would have to do proto.Equal on resources which is pretty expensive operation |
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.
There are other solutions to this (like per version resource values like how Delta is modeled), but it's probably fine to leave it as this for now.
…t-snapshot Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
@snowp I fixed comments and conflicts |
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!
@alecholmez for merge |
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.
This looks good @jakubdyszkiewicz, thanks for the contribution!
The implementation discussed in #433
SetSnapshot
andGetSnapshot
enables users to useLinearCache
in a more convenient way if the major use case is sendingDiscoveryRequest
with emptyresourceNames
.