resources

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2018 License: Apache-2.0 Imports: 5 Imported by: 24

Documentation

Index

Constants

View Source
const (
	NameCPUs  = Name("cpus")
	NameDisk  = Name("disk")
	NameGPUs  = Name("gpus")
	NameMem   = Name("mem")
	NamePorts = Name("ports")
)

Variables

This section is empty.

Functions

func CPUs

func CPUs(resources ...mesos.Resource) (float64, bool)

func Contains

func Contains(subject []mesos.Resource, that mesos.Resource) bool

func ContainsAll

func ContainsAll(subject, that []mesos.Resource) bool

ContainsAll returns true if this set of resources contains that set of (presumably pre-validated) resources.

func Disk

func Disk(resources ...mesos.Resource) (uint64, bool)

func Equivalent

func Equivalent(subject, that []mesos.Resource) bool

func Find

func Find(wants mesos.Resources, from ...mesos.Resource) (total mesos.Resources)

func Flatten

func Flatten(resources []mesos.Resource, opts ...FlattenOpt) []mesos.Resource

Flatten is deprecated and should only be used when dealing w/ resources in pre-reservation-refinement format.

func GPUs

func GPUs(resources ...mesos.Resource) (uint64, bool)

func Memory

func Memory(resources ...mesos.Resource) (uint64, bool)

func Ports

func Ports(resources ...mesos.Resource) (mesos.Ranges, bool)

func Reduce

func Reduce(rf Reducer, rs ...mesos.Resource) (r *mesos.Resource)

Reduce applies the given Reducer to produce a final Resource, iterating left-to-right over the given resources; panics if the Reducer is nil.

func SumAndCompare

func SumAndCompare(expected []mesos.Resource, resources ...mesos.Resource) bool

func TypesOf

func TypesOf(resources ...mesos.Resource) map[Name]mesos.Value_Type

func Validate

func Validate(resources ...mesos.Resource) error

Types

type Builder

type Builder struct{ mesos.Resource }

Builder simplifies construction of Resource objects

func Build

func Build() *Builder

func NewCPUs

func NewCPUs(value float64) *Builder

func NewDisk

func NewDisk(value float64) *Builder

func NewGPUs

func NewGPUs(value uint) *Builder

func NewMemory

func NewMemory(value float64) *Builder

func (*Builder) Disk

func (rb *Builder) Disk(persistenceID, containerPath string) *Builder

func (*Builder) DiskSource

func (rb *Builder) DiskSource(root string, t mesos.Resource_DiskInfo_Source_Type) *Builder

func (*Builder) Name

func (rb *Builder) Name(name fmt.Stringer) *Builder

func (*Builder) Ranges

func (rb *Builder) Ranges(rs mesos.Ranges) *Builder

func (*Builder) Revocable

func (rb *Builder) Revocable() *Builder

func (*Builder) Role

func (rb *Builder) Role(role string) *Builder

func (*Builder) Scalar

func (rb *Builder) Scalar(x float64) *Builder

func (*Builder) Set

func (rb *Builder) Set(x ...string) *Builder

type FlattenOpt

type FlattenOpt func(interface{})

FlattenOpt is a functional option for resource flattening, via Flatten. Implementations are expected to type-narrow the given interface, matching against WithRole, WithReservation or both methods (see Role.Assign)

type Name

type Name string

func NamesOf

func NamesOf(resources ...mesos.Resource) (names []Name)

func (Name) Filter

func (n Name) Filter(r *mesos.Resource) bool

func (Name) String

func (n Name) String() string

String implements fmt.Stringer

func (Name) Sum

func (n Name) Sum(resources ...mesos.Resource) (*mesos.Resource, bool)

type Names

type Names []Name

func (Names) Len

func (ns Names) Len() int

func (Names) Less

func (ns Names) Less(i, j int) bool

func (Names) Sort

func (ns Names) Sort()

func (Names) Swap

func (ns Names) Swap(i, j int)

type RangeBuilder

type RangeBuilder struct{ mesos.Ranges }

RangeBuilder simplifies construction of Range objects

func BuildRanges

func BuildRanges() *RangeBuilder

func (*RangeBuilder) Span

func (rb *RangeBuilder) Span(bp, ep uint64) *RangeBuilder

Span is a functional option for Ranges, defines the begin and end points of a continuous span within a range

type Reducer

type Reducer func(acc, x *mesos.Resource) *mesos.Resource

Reducer applies some operation to possibly combine an accumulator (acc) and a resource (x), returning either the combined result or nil.

func Sum

func Sum(fs ...resourcefilters.Filter) Reducer

func (Reducer) If

func (rf Reducer) If(f func(*mesos.Resource) bool) Reducer

If applies a filter func to a resource reducer; rejected resources are not processed by the receiving reducer.

func (Reducer) IfNot

func (rf Reducer) IfNot(f func(*mesos.Resource) bool) Reducer

IfNot applies a filter func to a resource reducer; accepted resources are not processed by the receiving reducer.

Jump to

Keyboard shortcuts

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