events

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: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decorator

type Decorator func(Handler) Handler

Decorator functions typically modify behavior of the given delegate Handler.

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(*executor.Event) error
}

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

type HandlerFunc

type HandlerFunc func(*executor.Event) error

HandlerFunc is a functional adaptation of the Handler interface

func (HandlerFunc) HandleEvent

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

HandleEvents implements Handler for HandlerFunc

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 *executor.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 executor.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.

Jump to

Keyboard shortcuts

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