Quantities
Many services need to represent a discrete quantity of items (number of bytes, number of miles, number of nodes, etc.).
Guidance
Quantities with a clear unit of measurement (such as bytes, miles, and so on)
must include the unit of measurement as the suffix. When appropriate and
unambiguous, units should use generally accepted abbreviations (for
example, distance_km
rather than distance_kilometers
).
If the quantity is a number of items (for example, the number of nodes in a
cluster), then the field should use the suffix _count
(not the prefix
num_
):
Specialized messages
It is sometimes useful to create a message that represents a particular quantity. This is particularly valuable in two situations.
- Grouping two or more individual quantities together.
- Representing a common concept where the unit of measurement may itself vary.
Consider the example of money, which could need to do both of these:
APIs may create structs to represent quantities when appropriate. When using these structs as fields, APIs should use the name of the struct as the suffix for the field name if it makes intuitive sense to do so.
Changelog
- 2019-09-13: Added the prohibition on unsigned types.