Documentation ¶
Overview ¶
package constraints contains methods for decoding a compact CPU and Memory constraints format. We specify the "constraints" format as the following:
<cpushare>:<memory limit>
CPUShare can be any number between 2 and 1024. For more details on how the --cpu-shares flag works in Docker/cgroups, see https://docs.docker.com/reference/run/#cpu-share-constraint
Memory limit can contain a number and optionally the units. The following are all equivalent:
6GB 6144MB 6291456KB
Index ¶
Constants ¶
const ConstraintsSeparator = ":"
ConstraintsSeparator separates the individual resource constraints
Variables ¶
var ( ErrInvalidMemory = errors.New("invalid memory format") ErrInvalidConstraint = errors.New("invalid constraints format") )
Functions ¶
This section is empty.
Types ¶
type CPUShare ¶
type CPUShare int
CPUShare represents a CPUShare.
func NewCPUShare ¶
NewCPUShare casts i to a CPUShare and ensures its validity.
func ParseCPUShare ¶
type Constraints ¶
Constraints is a composition of CPUShares, Memory and Nproc constraints.
func Parse ¶
func Parse(s string) (Constraints, error)
type Memory ¶
type Memory uint
Memory represents a memory limit.
func ParseMemory ¶
ParseMemory parses a string in memory format and returns the amount of memory in bytes.