task

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2015 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadConfig            = errors.New("bad-config")
	ErrBadConfigInfo        = errors.New("bad-config-info")
	ErrBadConfigStatus      = errors.New("bad-config-status")
	ErrBadConfigSuccess     = errors.New("bad-config-success")
	ErrBadConfigError       = errors.New("bad-config-error")
	ErrBadConfigCmdNotFound = errors.New("bad-config-cmd-not-found")

	ErrStopped = errors.New("stopped")
	ErrTimeout = errors.New("timeout")
)
View Source
var (
	ErrCommandUnknown = errors.New("command-unknown")
	ErrExecFailed     = errors.New("exec-failed")
)

Functions

This section is empty.

Types

type Announce added in v1.0.2

type Announce struct {
	Key       string
	Value     interface{}
	Ephemeral bool
}

type Cmd

type Cmd struct {
	Dir  string   `json:"working_dir,omitempty"`
	Path string   `json:"path"`
	Args []string `json:"args"`
	Env  []string `json:"env"`
}

func (*Cmd) ApplySubstitutions

func (this *Cmd) ApplySubstitutions(env map[string]interface{}, funcs template.FuncMap) (*Cmd, error)

Given the environments apply any substitutions to the command and args the format is same as template expressions e.g. {{.RUN_BINARY}} This allows the environment to be passed to the command even if the child process does not look at environment variables.

func (*Cmd) Copy

func (this *Cmd) Copy() (*Cmd, error)

/ Makes a deep copy

type CronExpression

type CronExpression string

type Runtime

type Runtime struct {
	Task

	TimestampStart int64
	TimestampExit  int64

	Status string
	// contains filtered or unexported fields
}

func (*Runtime) Announce added in v1.0.2

func (this *Runtime) Announce() chan<- Announce

func (*Runtime) ApplyEnvAndFuncs

func (this *Runtime) ApplyEnvAndFuncs(env map[string]interface{}, funcs map[string]interface{}) error

func (*Runtime) CaptureStdout

func (this *Runtime) CaptureStdout()

func (*Runtime) Error

func (this *Runtime) Error(error interface{}) error

func (*Runtime) GetCapturedStdout

func (this *Runtime) GetCapturedStdout() []byte

func (*Runtime) Log

func (this *Runtime) Log(m ...interface{})

func (*Runtime) Now added in v1.0.2

func (this *Runtime) Now() int64

func (*Runtime) PublishStdin

func (this *Runtime) PublishStdin() io.Writer

func (*Runtime) Running

func (this *Runtime) Running() bool

func (*Runtime) Start

func (this *Runtime) Start() (chan error, error)

func (*Runtime) Stderr

func (this *Runtime) Stderr() io.Writer

func (*Runtime) Stdin

func (this *Runtime) Stdin() io.Reader

func (*Runtime) StdinInterceptor

func (this *Runtime) StdinInterceptor(f func(string) (string, bool))

func (*Runtime) Stdout

func (this *Runtime) Stdout() io.Writer

func (*Runtime) Stop

func (this *Runtime) Stop()

func (*Runtime) Success

func (this *Runtime) Success(output interface{}) error

type Task

type Task struct {
	// Required
	Id  string `json:"id,omitempty"`
	Cmd *Cmd   `json:"cmd,omitempty"`

	// If this is set to true then we only require id and command to be set
	ExecOnly bool `json:"exec_only"`

	Name TaskName `json:"name"`

	// Optional namespace for task related announcements in the regstry.
	Namespace *registry.Path `json:"namespace,omitempty"`

	// Optional success / error == for signaling other watchers
	Success *registry.Path `json:"success,omitempty"`
	Error   *registry.Path `json:"error,omitempty"`

	// Conditional execution
	Trigger *Trigger `json:"trigger,omitempty"`

	// Topics (e.g. mqtt://localhost:1281/aws-cli/124/stdout)
	LogTopic pubsub.Topic  `json:"log,omitempty"`
	Stdin    *pubsub.Topic `json:"stdin,omitempty"`
	Stdout   *pubsub.Topic `json:"stdout,omitempty"`
	Stderr   *pubsub.Topic `json:"stderr,omitempty"`

	Runs int `json:"runs,omitempty"`

	Stats TaskStats `json:"stats,omitempty"`

	LogTemplateStart   *string `json:"log_template_start,omitempty"`
	LogTemplateStop    *string `json:"log_template_stop,omitempty"`
	LogTemplateSuccess *string `json:"log_template_success,omitempty"`
	LogTemplateError   *string `json:"log_template_error,omitempty"`
	// contains filtered or unexported fields
}

func (*Task) Copy

func (this *Task) Copy() (*Task, error)

func (*Task) Init

func (this *Task) Init(zkc zk.ZK, options ...interface{}) (*Runtime, error)

func (*Task) Validate

func (this *Task) Validate() error

type TaskName

type TaskName string

type TaskStats added in v1.0.2

type TaskStats struct {
	Started   int64 `json:"started,omitempty"`
	Triggered int64 `json:"triggered,omitempty"`
	Success   int64 `json:"success,omitempty"`
	Error     int64 `json:"error,omitempty"`
}

Written to the Info path of the task

type Trigger

type Trigger struct {
	Cron     *CronExpression      `json:"cron,omitempty"`
	Registry *registry.Conditions `json:"registry,omitempty"`
}

TODO -- add ordering. Cron before Registry, or Registry activates cron

Jump to

Keyboard shortcuts

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