offers

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: Apache-2.0 Imports: 2 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultKeyFunc = KeyFunc(KeyFuncByOfferID)

DefaultKeyFunc indexes offers by their OfferID.

Functions

func KeyFuncByOfferID

func KeyFuncByOfferID(o *mesos.Offer) interface{}

Types

type Filter

type Filter interface {
	Accept(*mesos.Offer) bool
}

Filter accepts or rejects a mesos Offer

func ByAttributes

func ByAttributes(f func(attr []mesos.Attribute) bool) Filter

ByAttributes returns a Filter that accepts offers with an attribute set accepted by the provided Attribute filter func.

func ByExecutors

func ByExecutors(f func(exec []mesos.ExecutorID) bool) Filter

func ByHostname

func ByHostname(hostname string) Filter

ByHostname returns a Filter that accepts offers with a matching Hostname

func ByUnavailability

func ByUnavailability(f func(u *mesos.Unavailability) bool) Filter

func ContainsResources

func ContainsResources(wanted mesos.Resources) Filter

ContainsResources returns a filter that returns true if the Resources of an Offer contain the wanted Resources.

type FilterFunc

type FilterFunc func(*mesos.Offer) bool

FilterFunc returns true if the given Offer passes the filter

func (FilterFunc) Accept

func (f FilterFunc) Accept(o *mesos.Offer) bool

Accept implements Filter for FilterFunc

type Index

type Index map[interface{}]*mesos.Offer

Index is a convenience type wrapper for a dictionary of Offer messages

func NewIndex

func NewIndex(slice []mesos.Offer, kf KeyFunc) Index

NewIndex returns a new Index constructed from the list of mesos offers. If the KeyFunc is nil then offers are indexed by DefaultKeyFunc. The values of the returned Index are pointers to (not copies of) the offers of the slice receiver.

func (Index) Filter

func (offers Index) Filter(filter Filter) (result Index)

Filter returns the subset of the Index that matches the given filter.

func (Index) FilterNot

func (offers Index) FilterNot(filter Filter) Index

FilterNot returns the subset of the Index that does not match the given filter.

func (Index) Find

func (offers Index) Find(filter Filter) *mesos.Offer

Find returns the first Offer that passes the given filter function, or else nil if there are no passing offers.

func (Index) IDs

func (offers Index) IDs() []mesos.OfferID

IDs extracts the ID field from a Index of offers

func (Index) ToSlice

func (offers Index) ToSlice() (slice Slice)

ToSlice returns a Slice from the offers in the Index. The returned slice will contain shallow copies of the offers from the Index.

type KeyFunc

type KeyFunc func(*mesos.Offer) interface{}

KeyFunc generates a key used for indexing offers

type Slice

type Slice []mesos.Offer

Slice is a convenience type wrapper for a slice of mesos Offer messages

func (Slice) Filter

func (offers Slice) Filter(filter Filter) (result Slice)

Filter returns the subset of the Slice that matches the given filter.

func (Slice) FilterNot

func (offers Slice) FilterNot(filter Filter) Slice

FilterNot returns the subset of the Slice that does not match the given filter.

func (Slice) Find

func (offers Slice) Find(filter Filter) *mesos.Offer

Find returns the first Offer that passes the given filter function, or else nil if there are no passing offers.

func (Slice) IDs

func (offers Slice) IDs() []mesos.OfferID

IDs extracts the ID field from a Slice of offers

Jump to

Keyboard shortcuts

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