You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
846 B
33 lines
846 B
package cgroups
|
|
|
|
import "fmt"
|
|
|
|
//go:generate stringer -type=Controller -linecomment
|
|
|
|
const (
|
|
ControllerUndefined Controller = iota // undefined
|
|
ControllerPids // pids
|
|
ControllerCPU // cpu
|
|
ControllerMemory // memory
|
|
ControllerRdma // rdma
|
|
ControllerIo // io
|
|
)
|
|
|
|
type Controller int
|
|
|
|
func ParseController(in string) (Controller, error) {
|
|
switch in {
|
|
case ControllerPids.String():
|
|
return ControllerPids, nil
|
|
case ControllerCPU.String():
|
|
return ControllerCPU, nil
|
|
case ControllerMemory.String():
|
|
return ControllerMemory, nil
|
|
case ControllerRdma.String():
|
|
return ControllerRdma, nil
|
|
case ControllerIo.String():
|
|
return ControllerIo, nil
|
|
default:
|
|
return ControllerUndefined, fmt.Errorf("Controller(%s)", in)
|
|
}
|
|
}
|
|
|