package events

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

Index

Types

type Decorator

type Decorator func(Handler) Handler

Decorator functions typically modify behavior of the given delegate Handler.

func Metrics

func Metrics(harness xmetrics.Harness) Decorator

func (Decorator) Apply

func (d Decorator) Apply(h Handler) Handler

func (Decorator) If

func (d Decorator) If(b bool) Decorator

If returns the receiving Decorator if the given bool is true; otherwise returns a no-op Decorator instance.

func (Decorator) When

func (d Decorator) When(f func() bool) Decorator

When returns a Decorator that evaluates the bool func every time the Handler is invoked. When f returns true, the Decorated Handler is invoked, otherwise the original Handler is.

type Decorators

type Decorators []Decorator

Decorators aggregates Decorator functions

func (Decorators) Apply

func (ds Decorators) Apply(h Handler) Handler

Apply applies the Decorators in the order they're listed such that the last Decorator invoked generates the final (wrapping) Handler that is ultimately returned.

type Handler

type Handler interface {
	HandleEvent(*scheduler.Event) error
}

Handler is invoked upon the occurrence of some scheduler event that is generated by some other component in the Mesos ecosystem (e.g. master, agent, executor, etc.)

func AcknowledgeUpdates

func AcknowledgeUpdates(callerGetter func() calls.Caller) Handler

AcknowledgeUpdates generates a Handler that sends an Acknowledge call to Mesos for every UPDATE event that's received.

func Once

func Once(h Handler) Handler

func OnceFunc

func OnceFunc(h HandlerFunc) Handler

func When

func When(p Happens, h Handler) Handler

func WhenFunc

func WhenFunc(p Happens, h HandlerFunc) Handler

type HandlerFunc

type HandlerFunc func(*scheduler.Event) error

HandlerFunc is a functional adaptation of the Handler interface

func (HandlerFunc) HandleEvent

func (f HandlerFunc) HandleEvent(e *scheduler.Event) error

HandleEvent implements Handler for HandlerFunc

type Handlers

type Handlers []Handler

Handlers aggregates Handler things

func (Handlers) HandleEvent

func (hs Handlers) HandleEvent(e *scheduler.Event) (err error)

HandleEvent implements Handler for Handlers

type Happens

type Happens interface {
	Happens() scheduler.EventPredicate
}

type Mux

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

Mux maps event types to Handlers (only one Handler for each type). A "default" Handler implementation may be provided to handle cases in which there is no registered Handler for specific event type.

func NewMux

func NewMux(opts ...Option) *Mux

NewMux generates and returns a new, empty Mux instance.

func (*Mux) HandleEvent

func (m *Mux) HandleEvent(e *scheduler.Event) (err error)

HandleEvent implements Handler for Mux

func (*Mux) With

func (m *Mux) With(opts ...Option) Option

With applies the given options to the Mux and returns the result of invoking the last Option func. If no options are provided then a no-op Option is returned.

type Option

type Option func(*Mux) Option

Option is a functional configuration option that returns an "undo" option that reverts the change made by the option.

func DefaultHandler

func DefaultHandler(eh Handler) Option

DefaultHandler returns an option that configures the default handler that's invoked in cases where there is no Handler registered for specific event type.

func Handle

func Handle(et scheduler.Event_Type, eh Handler) Option

Handle returns an option that configures a Handler to handle a specific event type. If the specified Handler is nil then any currently registered Handler for the given event type is deleted upon application of the returned Option.

func Map

func Map(handlers map[scheduler.Event_Type]Handler) (option Option)

Map returns an Option that configures multiple Handler objects.

func MapFuncs

func MapFuncs(handlers map[scheduler.Event_Type]HandlerFunc) (option Option)

MapFuncs is the functional adaptation of Map

type PredicateBool

type PredicateBool func() bool

func (PredicateBool) Happens

Source Files

decorators.go events.go metrics.go predicates.go

Version
v0.0.3
Published
Jun 19, 2017
Platform
windows/amd64
Imports
4 packages
Last checked
1 hour ago

Tools for package owners.