controller

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: 11 Imported by: 11

Documentation

Index

Constants

View Source
const DefaultEventLabel = "event"

DefaultEventLabel is, by default, logged as the first argument by DefaultEventLogger

View Source
const DefaultHandler = events.NoopHandler

DefaultHandler is invoked when no other handlers have been defined for the controller. The current implementation does nothing. TODO(jdef) a smarter default impl would decline all offers so as to avoid resource hoarding.

Variables

This section is empty.

Functions

func AckOperationUpdates added in v0.0.7

func AckOperationUpdates(caller calls.Caller) Rule

AckOperationUpdates acknowledges an offer operation status update sent to the scheduler by the master. The AgentID isn't part of the event reported by the master, so it cannot be included in the generated ACK.

func AckOperationUpdatesF added in v0.0.7

func AckOperationUpdatesF(callerLookup func() calls.Caller) Rule

AckOperationUpdatesF is a functional adapter for AckOperationUpdates, useful for cases where the caller may change over time. An error that occurs while ack'ing the status update is returned as a calls.AckError.

func AckStatusUpdates added in v0.0.4

func AckStatusUpdates(caller calls.Caller) Rule

AckStatusUpdates sends an acknowledgement of a task status update back to mesos and drops the event if sending the ack fails. If successful, the specified err param (if any) is forwarded. Acknowledgements are only attempted for task status updates tagged with a UUID.

func AckStatusUpdatesF added in v0.0.4

func AckStatusUpdatesF(callerLookup func() calls.Caller) Rule

AckStatusUpdatesF is a functional adapter for AckStatusUpdates, useful for cases where the caller may change over time. An error that occurs while ack'ing the status update is returned as a calls.AckError.

func DefaultEventLogger added in v0.0.4

func DefaultEventLogger(eventLabel string) func(*scheduler.Event)

DefaultEventLogger logs the event via the `log` package.

func LiftErrors added in v0.0.4

func LiftErrors() Rule

LiftErrors extract the error message from a scheduler error event and returns it as an ErrEvent so that downstream rules/handlers may continue processing.

func LogEvents added in v0.0.4

func LogEvents(f func(*scheduler.Event)) Rule

LogEvents returns a rule that logs scheduler events to the EventLogger

func Run added in v0.0.4

func Run(ctx context.Context, framework *mesos.FrameworkInfo, caller calls.Caller, options ...Option) (lastErr error)

Run executes a control loop that registers a framework with Mesos and processes the scheduler events that flow through the subscription. Upon disconnection, if the current configuration reports "not done" then the controller will attempt to re-register the framework and continue processing events.

func TrackSubscription added in v0.0.4

func TrackSubscription(frameworkIDStore store.Singleton, failoverTimeout time.Duration) Rule

Types

type Config

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

Config is an opaque controller configuration. Properties are configured by applying Option funcs.

type ErrEvent

type ErrEvent string

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

func (ErrEvent) Error

func (e ErrEvent) Error() string

type Option added in v0.0.4

type Option func(*Config) Option

Option modifies a Config, returns an Option that acts as an "undo"

func WithContextPerSubscription added in v0.0.9

func WithContextPerSubscription(b bool) Option

WithContextPerSubscription results in the creation of a sub-context that is passed to all event handlers and is canceled when the associated subscription has termined (i.e. when the event loop exits and a re- subscribe attempt is (possibly) attempted).

func WithEventHandler added in v0.0.4

func WithEventHandler(handler events.Handler) Option

WithEventHandler sets the consumer of 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.

func WithFrameworkID added in v0.0.4

func WithFrameworkID(frameworkIDFunc func() string) Option

WithFrameworkID sets a fetcher for the current Mesos-assigned framework ID. Frameworks are expected to track this ID (that comes from Mesos, in a SUBSCRIBED event). frameworkIDFunc is optional; nil tells the controller to always register as a new framework for each subscription attempt.

func WithInitiallySuppressedRoles added in v0.0.9

func WithInitiallySuppressedRoles(r []string) Option

WithInitiallySuppressedRoles sets the "suppressed_roles" field of the SUBSCRIBE call that's issued to Mesos for each (re-)subscription attempt.

func WithRegistrationTokens added in v0.0.4

func WithRegistrationTokens(registrationTokens <-chan struct{}) Option

WithRegistrationTokens limits the rate at which a framework (re)registers with Mesos. A non-nil chan should yield a struct{} in order to allow the framework registration process to continue. When nil, there is no backoff delay between re-subscription attempts. A closed chan disables re-registration and terminates the Run control loop.

func WithSubscriptionTerminated added in v0.0.4

func WithSubscriptionTerminated(handler func(error)) Option

WithSubscriptionTerminated sets a handler that is invoked at the end of every subscription cycle; the given error may be nil if no error occurred. subscriptionTerminated is optional; if nil then errors are swallowed.

type StateError added in v0.0.4

type StateError string

StateError is returned when the system encounters an unresolvable state transition error and should likely exit.

func (StateError) Error added in v0.0.4

func (err StateError) Error() string

Jump to

Keyboard shortcuts

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