controller

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2017 License: Apache-2.0 Imports: 5 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultHandler

func DefaultHandler(e *scheduler.Event) (err error)

DefaultHandler provides the minimum implementation required for correct controller behavior.

Types

type Config

type Config struct {
	Context   Context              // Context is required
	Framework *mesos.FrameworkInfo // FrameworkInfo is required
	Caller    calls.Caller         // Caller  is required

	// Handler (optional) processes scheduler events. The controller's internal event processing
	// loop is aborted if a Handler returns a non-nil error, after which the controller may attempt
	// to re-register (subscribe) with Mesos.
	Handler events.Handler

	// RegistrationTokens (optional) limits the rate at which a framework (re)registers with Mesos.
	// The returned chan should either be non-blocking (nil/closed), or should yield a struct{} in
	// order to allow the framework registration process to continue. May be nil.
	RegistrationTokens <-chan struct{}
}

type Context

type Context interface {
	// Done returns true when the controller should exit
	Done() bool

	// FrameworkID returns the current Mesos-assigned framework ID. Frameworks are expected to
	// track this ID (that comes from Mesos, in a SUBSCRIBED event).
	FrameworkID() string

	// Error is an error handler that is invoked at the end of every subscription cycle; the given
	// error may be nil (if no errors occurred).
	Error(error)
}

type ContextAdapter

type ContextAdapter struct {
	// FrameworkIDFunc is optional; nil tells the controller to always register as a new framework
	// for each subscription attempt.
	FrameworkIDFunc func() string

	// Done is optional; nil equates to a func that always returns false
	DoneFunc func() bool

	// ErrorFunc is optional; if nil then errors are swallowed
	ErrorFunc func(error)
}

func (*ContextAdapter) Done

func (ca *ContextAdapter) Done() bool

func (*ContextAdapter) Error

func (ca *ContextAdapter) Error(err error)

func (*ContextAdapter) FrameworkID

func (ca *ContextAdapter) FrameworkID() (id string)

type Controller

type Controller interface {
	// Run executes the controller using the given Config
	Run(Config) error
}

func New

func New() Controller

type ControllerFunc

type ControllerFunc func(Config) error

ControllerFunc is a functional adaptation of a Controller

func (ControllerFunc) Run

func (cf ControllerFunc) Run(config Config) error

Run implements Controller for ControllerFunc

type ErrEvent

type ErrEvent string

ErrEvent errors are generated by the DefaultHandler upon receiving an ERROR event from Mesos.

func (ErrEvent) Error

func (e ErrEvent) Error() string

Jump to

Keyboard shortcuts

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