utils

package module
v0.0.0-...-0142cf9 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2016 License: Apache-2.0 Imports: 19 Imported by: 8

README

go-mesos-utils

Documentation

Index

Constants

View Source
const (
	ResourceCpus  = "cpus"
	ResourceMem   = "mem"
	ResourceDisk  = "disk"
	ResourcePorts = "ports"
)

Variables

This section is empty.

Functions

func CheckConstraints

func CheckConstraints(offer *mesos.Offer, taskConstraints map[string][]Constraint, otherTasks []Constrained) string

func Environment

func Environment(vars map[string]string) *mesos.Environment

func GetRangeResources

func GetRangeResources(offer *mesos.Offer, resourceName string) []*mesos.Value_Range

func GetScalarResources

func GetScalarResources(offer *mesos.Offer, resourceName string) float64

func OfferAttributes

func OfferAttributes(offer *mesos.Offer) map[string]string

func StringToLabels

func StringToLabels(s string) *mesos.Labels

Convert param string like "param1=value1;param2=value2" to mesos.Labels

func TaskMatches

func TaskMatches(data *TaskData, offer *mesos.Offer) string

Types

type Cluster

type Cluster struct {
	// contains filtered or unexported fields
}

func NewClusterConstraint

func NewClusterConstraint(value string) *Cluster

func (*Cluster) Matches

func (c *Cluster) Matches(value string, values []string) bool

func (*Cluster) String

func (c *Cluster) String() string

type Constrained

type Constrained interface {
	Constraints() map[string][]Constraint
	Attribute(name string) string
}

type Constraint

type Constraint interface {
	Matches(value string, values []string) bool
}

func MustParseConstraint

func MustParseConstraint(value string) Constraint

func ParseConstraint

func ParseConstraint(value string) (Constraint, error)

type Constraints

type Constraints map[string][]Constraint

func (Constraints) MarshalJSON

func (c Constraints) MarshalJSON() ([]byte, error)

func (Constraints) UnmarshalJSON

func (c Constraints) UnmarshalJSON(data []byte) error

type DefaultLogger

type DefaultLogger struct {
	// contains filtered or unexported fields
}

DefaultLogger is a default implementation of Log interface used in this client.

func NewDefaultLogger

func NewDefaultLogger(Level LogLevel) *DefaultLogger

NewDefaultLogger creates a new DefaultLogger that is configured to write messages to console with minimum log level Level.

func (*DefaultLogger) Critical

func (dl *DefaultLogger) Critical(message string, params ...interface{})

Critical formats a given message according to given params to log with level Critical.

func (*DefaultLogger) Debug

func (dl *DefaultLogger) Debug(message string, params ...interface{})

Debug formats a given message according to given params to log with level Debug.

func (*DefaultLogger) Error

func (dl *DefaultLogger) Error(message string, params ...interface{})

Error formats a given message according to given params to log with level Error.

func (*DefaultLogger) Info

func (dl *DefaultLogger) Info(message string, params ...interface{})

Info formats a given message according to given params to log with level Info.

func (*DefaultLogger) Trace

func (dl *DefaultLogger) Trace(message string, params ...interface{})

Trace formats a given message according to given params to log with level Trace.

func (*DefaultLogger) Warn

func (dl *DefaultLogger) Warn(message string, params ...interface{})

Warn formats a given message according to given params to log with level Warn.

type FileStorage

type FileStorage struct {
	// contains filtered or unexported fields
}

func NewFileStorage

func NewFileStorage(file string) *FileStorage

func (*FileStorage) Load

func (fs *FileStorage) Load() ([]byte, error)

func (*FileStorage) Save

func (fs *FileStorage) Save(contents []byte) error

func (*FileStorage) String

func (fs *FileStorage) String() string

type GroupBy

type GroupBy struct {
	// contains filtered or unexported fields
}

func NewGroupByConstraint

func NewGroupByConstraint(groups int) *GroupBy

func (*GroupBy) Matches

func (g *GroupBy) Matches(value string, values []string) bool

func (*GroupBy) String

func (g *GroupBy) String() string

type Like

type Like struct {
	// contains filtered or unexported fields
}

func NewLikeConstraint

func NewLikeConstraint(regex string) (*Like, error)

func (*Like) Matches

func (l *Like) Matches(value string, values []string) bool

func (*Like) String

func (l *Like) String() string

type Log

type Log interface {
	//Formats a given message according to given params to log with level Trace.
	Trace(message string, params ...interface{})

	//Formats a given message according to given params to log with level Debug.
	Debug(message string, params ...interface{})

	//Formats a given message according to given params to log with level Info.
	Info(message string, params ...interface{})

	//Formats a given message according to given params to log with level Warn.
	Warn(message string, params ...interface{})

	//Formats a given message according to given params to log with level Error.
	Error(message string, params ...interface{})

	//Formats a given message according to given params to log with level Critical.
	Critical(message string, params ...interface{})
}

Log is a logger interface. Lets you plug-in your custom logging library instead of using built-in one.

Logger used by this client. Defaults to build-in logger with Info log level.

type LogLevel

type LogLevel string

LogLevel represents a logging level.

const (
	// TraceLevel is used for debugging to find problems in functions, variables etc.
	TraceLevel LogLevel = "trace"

	// DebugLevel is used for detailed system reports and diagnostic messages.
	DebugLevel LogLevel = "debug"

	// InfoLevel is used for general information about a running application.
	InfoLevel LogLevel = "info"

	// WarnLevel is used to indicate small errors and failures that should not happen normally but are recovered automatically.
	WarnLevel LogLevel = "warn"

	// ErrorLevel is used to indicate severe errors that affect application workflow and are not handled automatically.
	ErrorLevel LogLevel = "error"

	// CriticalLevel is used to indicate fatal errors that may cause data corruption or loss.
	CriticalLevel LogLevel = "critical"
)

type Range

type Range struct {
	// contains filtered or unexported fields
}

func NewRange

func NewRange(start int, end int) *Range

func ParseRange

func ParseRange(s string) (*Range, error)

func ParseRanges

func ParseRanges(rawRanges string, sep string) ([]*Range, error)

func (*Range) End

func (r *Range) End() int

func (*Range) Overlap

func (r *Range) Overlap(r2 *Range) *Range

func (*Range) Start

func (r *Range) Start() int

func (*Range) String

func (r *Range) String() string

func (*Range) Values

func (r *Range) Values() []int

type Reconciler

type Reconciler struct {
	ReconcileDelay    time.Duration
	ReconcileMaxTries int
	// contains filtered or unexported fields
}

func NewReconciler

func NewReconciler() *Reconciler

func (*Reconciler) ExplicitReconcile

func (r *Reconciler) ExplicitReconcile(taskIDs []string, driver scheduler.SchedulerDriver)

func (*Reconciler) ImplicitReconcile

func (r *Reconciler) ImplicitReconcile(driver scheduler.SchedulerDriver)

func (*Reconciler) Update

func (r *Reconciler) Update(status *mesos.TaskStatus)

type Storage

type Storage interface {
	Save([]byte) error
	Load() ([]byte, error)
}

type Task

type Task interface {
	Config() TaskConfig
	Data() *TaskData
	Matches(*mesos.Offer) string
	NewTaskInfo(*mesos.Offer) *mesos.TaskInfo
}

type TaskConfig

type TaskConfig map[string]string

func (TaskConfig) GetString

func (tc TaskConfig) GetString(key string) string

type TaskData

type TaskData struct {
	Type          string
	ID            string
	TaskID        string
	SlaveID       string
	ExecutorID    string
	Attributes    map[string]string
	State         TaskState
	Cpu           float64
	Mem           float64
	ConstraintMap Constraints
}

also implements Constrained

func (*TaskData) Attribute

func (td *TaskData) Attribute(name string) string

func (*TaskData) Constraints

func (td *TaskData) Constraints() map[string][]Constraint

func (*TaskData) Reset

func (td *TaskData) Reset()

Reset resets executor-specific information for this task, e.g. TaskID, ExecutorID, SlaveID and Attributes

func (*TaskData) WaitFor

func (td *TaskData) WaitFor(state TaskState, timeout time.Duration) bool

type TaskState

type TaskState string
const (
	TaskStateInactive    TaskState = "inactive"
	TaskStateStopped     TaskState = "stopped"
	TaskStateStaging     TaskState = "staging"
	TaskStateRunning     TaskState = "running"
	TaskStateReconciling TaskState = "reconciling"
)

type Tasks

type Tasks interface {
	Exists(id string) bool
	Add(task Task)
	Remove(id string)
	Get(id string) Task
	GetAll() []Task
	GetWithFilter(filter func(Task) bool) []Task
	GetStopped() []Task
	IsReconciling() bool
	GetConstrained() []Constrained
}

func NewTasks

func NewTasks() Tasks

func NewThreadSafeTasks

func NewThreadSafeTasks() Tasks

type Unique

type Unique struct{}

func NewUniqueConstraint

func NewUniqueConstraint() *Unique

func (*Unique) Matches

func (u *Unique) Matches(value string, values []string) bool

func (*Unique) String

func (u *Unique) String() string

type Unlike

type Unlike struct {
	// contains filtered or unexported fields
}

func NewUnlikeConstraint

func NewUnlikeConstraint(regex string) (*Unlike, error)

func (*Unlike) Matches

func (u *Unlike) Matches(value string, values []string) bool

func (*Unlike) String

func (u *Unlike) String() string

type ZKStorage

type ZKStorage struct {
	// contains filtered or unexported fields
}

func NewZKStorage

func NewZKStorage(zk string) (*ZKStorage, error)

func (*ZKStorage) Load

func (zs *ZKStorage) Load() ([]byte, error)

func (*ZKStorage) Save

func (zs *ZKStorage) Save(contents []byte) error

func (*ZKStorage) String

func (zs *ZKStorage) String() string

Directories

Path Synopsis
Package pretty provides human-readable representations for some general Mesos entities.
Package pretty provides human-readable representations for some general Mesos entities.

Jump to

Keyboard shortcuts

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