Skip to content
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

Merged
merged 4 commits into from
Jun 25, 2021
Merged

cache: add SetSnapshot and GetSnapshot to LinearCache #437

merged 4 commits into from
Jun 25, 2021

Conversation

jakubdyszkiewicz
Copy link
Contributor

The implementation discussed in #433

SetSnapshot and GetSnapshot enables users to use LinearCache in a more convenient way if the major use case is sending DiscoveryRequest with empty resourceNames.

Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
@jakubdyszkiewicz
Copy link
Contributor Author

Sorry about the force push 🙏 I started the work from master instead of main.

@alecholmez
Copy link
Contributor

Thanks for opening this! I'll review

Copy link
Contributor

@alecholmez alecholmez left a 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

pkg/cache/v3/linear.go Outdated Show resolved Hide resolved
pkg/cache/v3/linear.go Outdated Show resolved Hide resolved
pkg/cache/v3/linear.go Outdated Show resolved Hide resolved
Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
@jakubdyszkiewicz
Copy link
Contributor Author

hey, @alecholmez do you have any more suggestions?

@alecholmez
Copy link
Contributor

@jakubdyszkiewicz I think this is good from my end, can you address the merge conflicts?

@snowp you have any thoughts?

Copy link
Contributor

@snowp snowp left a 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

pkg/cache/v3/linear.go Outdated Show resolved Hide resolved
pkg/cache/v3/linear.go Outdated Show resolved Hide resolved
cache.version += 1

modified := map[string]struct{}{}
for name := range cache.resources {
Copy link
Contributor

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

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
Copy link
Contributor

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.

pkg/cache/v3/linear_test.go Outdated Show resolved Hide resolved
…t-snapshot

Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
@jakubdyszkiewicz
Copy link
Contributor Author

jakubdyszkiewicz commented Jun 22, 2021

@snowp I fixed comments and conflicts

Copy link
Contributor

@snowp snowp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@snowp
Copy link
Contributor

snowp commented Jun 22, 2021

@alecholmez for merge

Copy link
Contributor

@alecholmez alecholmez left a 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!

@alecholmez alecholmez merged commit 7f733d5 into envoyproxy:main Jun 25, 2021
@jakubdyszkiewicz jakubdyszkiewicz deleted the linear-cache-set-snapshot branch June 28, 2021 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants