-
Notifications
You must be signed in to change notification settings - Fork 6
feat(BREV-2083): Split Byte Sizes into Value and Unit #55
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5e44449
feat(BREV-2083): Capture both byte value and unit in size
drewmalin b779132
implement memory
drewmalin 3cb9dca
lint
drewmalin 9dd02d5
include gpu memory
drewmalin 799b781
include gpu memory
drewmalin df5fca2
check for overflow
drewmalin 1bd20d1
lint
drewmalin 6b5ecf5
lint
drewmalin a5a3a3a
createinstanceattrs
drewmalin ff154e8
disk
drewmalin 88d0868
interface
drewmalin 02a06e6
no pointers to interfaces
drewmalin f1cb4ad
remove interface, move to int64
drewmalin 521b7df
use bytes moniker
drewmalin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package v1 | ||
|
|
||
| var zeroBytes = Bytes{value: 0, unit: Byte} | ||
|
|
||
| // NewBytes creates a new Bytes with the given value and unit | ||
| func NewBytes(value BytesValue, unit BytesUnit) Bytes { | ||
| if value < 0 { | ||
| return zeroBytes | ||
| } | ||
| return Bytes{ | ||
| value: value, | ||
| unit: unit, | ||
| } | ||
| } | ||
|
|
||
| type ( | ||
| BytesValue int64 | ||
| BytesUnit string | ||
| ) | ||
|
|
||
| // Bytes represents a number of some unit of bytes | ||
| type Bytes struct { | ||
| value BytesValue | ||
| unit BytesUnit | ||
| } | ||
|
|
||
| // Value is the whole non-negative number of bytes of the specified unit | ||
| func (b Bytes) Value() BytesValue { | ||
| return b.value | ||
| } | ||
|
|
||
| // Unit is the unit of the byte value | ||
| func (b Bytes) Unit() BytesUnit { | ||
| return b.unit | ||
| } | ||
|
|
||
| // ByteUnit is a unit of measurement for bytes | ||
| const ( | ||
| Byte BytesUnit = "B" | ||
|
|
||
| // Base 10 | ||
| Kilobyte BytesUnit = "KB" | ||
| Megabyte BytesUnit = "MB" | ||
| Gigabyte BytesUnit = "GB" | ||
| Terabyte BytesUnit = "TB" | ||
| Petabyte BytesUnit = "PB" | ||
| Exabyte BytesUnit = "EB" | ||
|
|
||
| // Base 2 | ||
| Kibibyte BytesUnit = "KiB" | ||
| Mebibyte BytesUnit = "MiB" | ||
| Gibibyte BytesUnit = "GiB" | ||
| Tebibyte BytesUnit = "TiB" | ||
| Pebibyte BytesUnit = "PiB" | ||
| Exbibyte BytesUnit = "EiB" | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
the internet says that changing this to
// Deprecated: TODO deprecate in favor of DiskSizeByteValuewill actually mark this as deprecated. Though do you actually want to do that, or defer that change?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 am a little worried it will blow up our linter but could give it a shot...