resources

package
v0.14.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResCPU     = "cpu"
	ResMemory  = "memory"
	ResStorage = "storage"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Quantity

type Quantity int64

Quantity defines value type

func ParseMilliQuantity

func ParseMilliQuantity(value string) (Quantity, error)

ParseMilliQuantity is used to parse user-provided values into milli int64.

func ParseQuantity

func ParseQuantity(value string) (Quantity, error)

ParseQuantity is used to parse user-provided values into int64.

func (Quantity) AsInt64 added in v0.14.6

func (q Quantity) AsInt64() int64

func (Quantity) MemString

func (q Quantity) MemString() string

func (Quantity) MilliString

func (q Quantity) MilliString() string

func (Quantity) String

func (q Quantity) String() string

type Resource

type Resource struct {
	Resources map[string]Quantity `json:"-"`
}

Resource is a struct that contains the information of a resource. For cpu resource, the unit of cpu value is milli

func EmptyResource

func EmptyResource() *Resource

func NewResourceFromMap

func NewResourceFromMap(resourceInfo map[string]string) (*Resource, error)

func (*Resource) Add

func (r *Resource) Add(rr *Resource)

Add additional resource to the base and updating the base resource Should be used by temporary computation only

func (*Resource) CPU

func (r *Resource) CPU() Quantity

func (*Resource) Clone

func (r *Resource) Clone() *Resource

Clone Return a deep copy of the resource it is called on.

func (*Resource) DelResources

func (r *Resource) DelResources(name string)

func (*Resource) IsNegative

func (r *Resource) IsNegative() bool

func (*Resource) IsZero added in v0.14.6

func (r *Resource) IsZero() bool

IsZero check if exist any zero resource

func (*Resource) LessEqual

func (r *Resource) LessEqual(rr *Resource) bool

LessEqual returns true if this quantity is less than or equal to the other.

func (Resource) MarshalJSON

func (r Resource) MarshalJSON() ([]byte, error)

func (*Resource) Memory

func (r *Resource) Memory() Quantity

func (*Resource) Multi

func (r *Resource) Multi(ratio int)

Multi multiples the resource with ratio provided

func (*Resource) Resource added in v0.14.6

func (r *Resource) Resource() map[string]Quantity

Resource return all resources

func (*Resource) ScalarResources added in v0.14.4

func (r *Resource) ScalarResources(prefix string) map[string]Quantity

ScalarResources return scalar resources by prefix, if prefix is empty, return all

func (*Resource) SetResources

func (r *Resource) SetResources(name string, value int64)

func (*Resource) Storage added in v0.14.4

func (r *Resource) Storage() Quantity

func (Resource) String

func (r Resource) String() string

func (*Resource) Sub

func (r *Resource) Sub(rr *Resource)

Sub subtract from the resource the passed in resource by updating the resource it is called on. Should be used by temporary computation only

func (*Resource) ToMap added in v0.14.6

func (r *Resource) ToMap() map[string]interface{}

func (*Resource) UnmarshalJSON

func (r *Resource) UnmarshalJSON(value []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL