flow

package
v0.0.0-...-48c86bf Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Flow

type Flow struct {
	Name                    string
	Logger                  *logrus.Entry
	ProgressReporterFunc    func(int, string)
	DoneCh                  chan *Task
	RootTasks               TaskList
	ActiveTasks             TaskList
	ErrornousTasks          TaskList
	NumberOfExecutableTasks int
	NumberOfCompletedTasks  int
}

Flow is the definition of a flow.

func New

func New(name string) *Flow

New creates a new Flow object.

func (*Flow) AddSyncPoint

func (f *Flow) AddSyncPoint(dependsOn ...*Task) *Task

AddSyncPoint takes a list of tasks and returns a dummy task which can be used by others as dependency. With that, a long list of dependencies must only defined once.

func (*Flow) AddTask

func (f *Flow) AddTask(function func() error, retryDuration time.Duration, dependsOn ...*Task) *Task

AddTask takes a <function> and a <retryDuration> and returns a pointer to a Task object.

func (*Flow) AddTaskConditional

func (f *Flow) AddTaskConditional(function func() error, retryDuration time.Duration, condition bool, dependsOn ...*Task) *Task

AddTaskConditional takes a <function> and a <retryDuration> and returns a pointer to a Task object. In case the <condition> is false, the task will be marked as "skipped".

func (*Flow) Execute

func (f *Flow) Execute() *gardenv1beta1.LastError

Execute will execute all tasks in the flow.

func (*Flow) SetLogger

func (f *Flow) SetLogger(logger *logrus.Entry) *Flow

SetLogger will take a <logger> and store it on the Flow object. The logger will be used at the begin of each function invocation, and in case of errors.

func (*Flow) SetProgressReporter

func (f *Flow) SetProgressReporter(reporter func(int, string)) *Flow

SetProgressReporter will take a function <reporter> and store it on the Flow object. The function will be called whenever the state changes. It will receive the percentage of compeleted tasks of the Flow and the list of currently executed functions as arguments.

type Task

type Task struct {
	Function                    func() error
	RetryDuration               time.Duration
	Error                       *utilerrors.Error
	Skip                        bool
	TriggerTasks                TaskList
	NumberOfPendingDependencies int
}

Task is the definition of a task in the flow.

func (*Task) String

func (t *Task) String() string

String will returns the string representation of the task.

type TaskList

type TaskList []*Task

TaskList is a list of tasks.

func (TaskList) String

func (t TaskList) String() string

String will returns the string representation of the task list.

Jump to

Keyboard shortcuts

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