Documentation ¶
Index ¶
- Constants
- func AckOperationUpdates(caller calls.Caller) Rule
- func AckOperationUpdatesF(callerLookup func() calls.Caller) Rule
- func AckStatusUpdates(caller calls.Caller) Rule
- func AckStatusUpdatesF(callerLookup func() calls.Caller) Rule
- func DefaultEventLogger(eventLabel string) func(*scheduler.Event)
- func LiftErrors() Rule
- func LogEvents(f func(*scheduler.Event)) Rule
- func Run(ctx context.Context, framework *mesos.FrameworkInfo, caller calls.Caller, ...) (lastErr error)
- func TrackSubscription(frameworkIDStore store.Singleton, failoverTimeout time.Duration) Rule
- type Config
- type ErrEvent
- type Option
- func WithContextPerSubscription(b bool) Option
- func WithEventHandler(handler events.Handler) Option
- func WithFrameworkID(frameworkIDFunc func() string) Option
- func WithInitiallySuppressedRoles(r []string) Option
- func WithRegistrationTokens(registrationTokens <-chan struct{}) Option
- func WithSubscriptionTerminated(handler func(error)) Option
- type StateError
Constants ¶
const DefaultEventLabel = "event"
DefaultEventLabel is, by default, logged as the first argument by DefaultEventLogger
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
DefaultEventLogger logs the event via the `log` package.
func LiftErrors ¶
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 Run ¶
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.
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.
type Option ¶
Option modifies a Config, returns an Option that acts as an "undo"
func WithContextPerSubscription ¶
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 ¶
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 ¶
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 ¶
WithInitiallySuppressedRoles sets the "suppressed_roles" field of the SUBSCRIBE call that's issued to Mesos for each (re-)subscription attempt.
func WithRegistrationTokens ¶
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 ¶
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 ¶
type StateError string
StateError is returned when the system encounters an unresolvable state transition error and should likely exit.
func (StateError) Error ¶
func (err StateError) Error() string