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: Make Rows() return a map of UUID to Models #247

Merged
merged 1 commit into from
Oct 14, 2021

Conversation

dave-tucker
Copy link
Collaborator

@dave-tucker dave-tucker commented Oct 14, 2021

This makes Rows() return a map of UUID to Model.
These models are copies of those in the cache at the time Rows() was
called.

@coveralls
Copy link

coveralls commented Oct 14, 2021

Pull Request Test Coverage Report for Build 1343352222

  • 8 of 12 (66.67%) changed or added relevant lines in 3 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.02%) to 72.858%

Changes Missing Coverage Covered Lines Changed/Added Lines %
cache/cache.go 4 8 50.0%
Files with Coverage Reduction New Missed Lines %
client/client.go 1 67.64%
Totals Coverage Status
Change from base Build 1343346118: 0.02%
Covered Lines: 4056
Relevant Lines: 5567

💛 - Coveralls

@dave-tucker
Copy link
Collaborator Author

/cc @trozet this fixes one of the panics you found

@trozet
Copy link
Contributor

trozet commented Oct 14, 2021

@dave-tucker should the cache read have an RLock instead?

@trozet
Copy link
Contributor

trozet commented Oct 14, 2021

oh I see there is an RLock inside Rows and Row, but not in the API call

client/api.go Outdated Show resolved Hide resolved
@dave-tucker dave-tucker changed the title api: Perform nil checks when gettings rows from cache cache: Make Rows() return a map of UUID to Models Oct 14, 2021
@dave-tucker dave-tucker force-pushed the api-fix branch 2 times, most recently from 8334967 to 0556741 Compare October 14, 2021 17:19
@dave-tucker
Copy link
Collaborator Author

@trozet addressed this. rather than checking that elem != nil, Rows() now gives a copy of the cache, so it will never contain nil elements and therefore won't panic.

Copy link
Contributor

@trozet trozet left a comment

Choose a reason for hiding this comment

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

inline comment, otherwise lgtm

cache/cache.go Outdated Show resolved Hide resolved
cache/cache.go Outdated Show resolved Hide resolved
@dave-tucker
Copy link
Collaborator Author

@trozet removed the unncecessary calls to model.Clone

This makes Rows() return a map of UUID to Model.
These models are copies of those in the cache at the time Rows() was
called.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
@dave-tucker dave-tucker merged commit 28345b9 into ovn-org:main Oct 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants