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

feat: cache proxmox version in Client #312

Merged
merged 1 commit into from
Feb 7, 2024

Conversation

Tinyblargon
Copy link
Collaborator

Add Version() to the Client struct to return the cached PVE version and fetch it when we have no version yet.
This does add a mutex to the Client if this becomes a performance issue we can fix it using channels, but this would be more complex and require a dispatch thread.

closes #309


// Greater returns true if the version is greater than the other version.
func (v Version) Greater(other Version) bool {
return uint32(v.Major)*256*256+uint32(v.Minor)*256+uint32(v.Patch) > uint32(other.Major)*256*256+uint32(other.Minor)*256+uint32(other.Patch)
Copy link
Collaborator Author

@Tinyblargon Tinyblargon Feb 7, 2024

Choose a reason for hiding this comment

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

This is instead of multiple consecutive if statements. It needed a unit test anyways so might as well implement the most performant solution.
Minor 1 > Patch 255
Major 1 > (Minor 255 + Patch 255)

@Tinyblargon Tinyblargon changed the title feat: cache proxmox version in Client feat: cache proxmox version in Client Feb 7, 2024
@Tinyblargon Tinyblargon merged commit 173458c into Telmate:master Feb 7, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Cache proxmox version in Client
2 participants