package controller

import "github.com/mesos/mesos-go/api/v1/lib/extras/scheduler/controller"

Index

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

Source Files

controller.go

Version
v0.0.3
Published
Jun 19, 2017
Platform
js/wasm
Imports
5 packages
Last checked
1 hour ago

Tools for package owners.