offers

package
v1.1.0-alpha.0....-98e2ed6 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2015 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package offers contains code that manages Mesos offers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expired

func Expired(offerId, hostname string, ttl time.Duration) *expiredOffer

Types

type Filter

type Filter func(*mesos.Offer) bool

type Perishable

type Perishable interface {
	// returns true if this offer has expired
	HasExpired() bool
	// if not yet expired, return mesos offer details; otherwise nil
	Details() *mesos.Offer
	// mark this offer as acquired, returning true if it was previously unacquired. thread-safe.
	Acquire() bool
	// mark this offer as un-acquired. thread-safe.
	Release()

	// return a unique identifier for this offer
	Id() string
	// return the slave host for this offer
	Host() string
	// contains filtered or unexported methods
}

offers that may perish (all of them?) implement this interface. callers may expect to access these funcs concurrently so implementations must provide their own form of synchronization around mutable state.

type Registry

type Registry interface {
	// Initialize the instance, spawning necessary housekeeping go routines.
	Init(<-chan struct{})

	// Add offers to this registry, rejecting those that are deemed incompatible.
	Add([]*mesos.Offer)

	// Listen for arriving offers that are acceptable to the filter, sending
	// a signal on (by closing) the returned channel. A listener will only
	// ever be notified once, if at all.
	Listen(id string, f Filter) <-chan struct{}

	// invoked when offers are rescinded or expired
	Delete(string, metrics.OfferDeclinedReason)

	// when true, returns the offer that's registered for the given ID
	Get(offerId string) (Perishable, bool)

	// iterate through non-expired offers in this registry
	Walk(Walker) error

	// invalidate one or all (when offerId="") offers; offers are not declined,
	// but are simply flagged as expired in the offer history
	Invalidate(offerId string)

	// invalidate all offers associated with the slave identified by slaveId.
	InvalidateForSlave(slaveId string)
}

func CreateRegistry

func CreateRegistry(c RegistryConfig) Registry

type RegistryConfig

type RegistryConfig struct {
	DeclineOffer  func(offerId string) <-chan error // tell Mesos that we're declining the offer
	Compat        func(*mesos.Offer) bool           // returns true if offer is compatible; incompatible offers are declined
	TTL           time.Duration                     // determines a perishable offer's expiration deadline: now+ttl
	LingerTTL     time.Duration                     // if zero, offers will not linger in the FIFO past their expiration deadline
	ListenerDelay time.Duration                     // specifies the sleep time between offer listener notifications
}

type Walker

type Walker func(offer Perishable) (stop bool, err error)

callback that is invoked during a walk through a series of live offers, returning with stop=true (or err != nil) if the walk should stop permaturely.

Directories

Path Synopsis
Package metrics defines and exposes instrumentation metrics related to Mesos offers.
Package metrics defines and exposes instrumentation metrics related to Mesos offers.

Jump to

Keyboard shortcuts

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