workflow

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

README

workflow

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute added in v1.0.1

func Execute(ctx context.Context, task Task) error

func NewStack

func NewStack() *stack

func NewTimeWheel added in v1.0.1

func NewTimeWheel(interval time.Duration, slotNum int) *timeWheel

Types

type Callback added in v1.2.0

type Callback interface {
	Trigger(ctx context.Context, task Task)
}

type Dag

type Dag struct {
	Vertexes []*Vertex
	// contains filtered or unexported fields
}

Dag is directed acyclic graph

type DelayTask added in v1.0.1

type DelayTask struct {
	Delay time.Duration
	Task
}

type Executor

type Executor interface {
	Execute(ctx context.Context, task Task) error
}

type FuncExecutor added in v1.0.1

type FuncExecutor func(ctx context.Context, task Task) error

func (FuncExecutor) Execute added in v1.0.1

func (f FuncExecutor) Execute(ctx context.Context, task Task) error

type NoneNotify

type NoneNotify struct {
}

func (NoneNotify) Event

func (n NoneNotify) Event(ctx context.Context, format string, v ...interface{})

func (NoneNotify) Notify

func (n NoneNotify) Notify(ctx context.Context, name string, progress float32)

type Notifier

type Notifier interface {
	Event(ctx context.Context, format string, v ...interface{})
	Notify(ctx context.Context, name string, progress float32)
}

type Policy

type Policy uint8
const (
	PolicyRetry Policy = 1 + iota
	PolicyRevert
)

type RetryOption added in v1.0.1

type RetryOption func(*retryOption)

func WithAttempt

func WithAttempt(attempt int) RetryOption

func WithInterval

func WithInterval(interval time.Duration) RetryOption

func WithPolicy

func WithPolicy(policy Policy) RetryOption

type State added in v1.2.0

type State string
const (
	Ready   State = "ready"
	Running State = "running"
	Success State = "success"
	Error   State = "error"
)

type Storage

type Storage interface {
}

type Task

type Task interface {
	ID() string
	Name() string
	State() (State, error)
	Description() string
	CreateTime() time.Time
	UpdateTime() time.Time
	Meta() map[string]interface{}

	Commit(ctx context.Context, opts ...TaskOption) error
	Rollback(ctx context.Context, opts ...TaskOption) error
}

Task is library's minimum unit

func NewFuncTask

func NewFuncTask(f func(context.Context) error, opts ...TaskOption) Task

func ParallelTask

func ParallelTask(opts ...TaskOption) Task

func PipelineTask

func PipelineTask(opts ...TaskOption) Task

func RetryTask

func RetryTask(t Task, opts ...RetryOption) Task

func SafeTask

func SafeTask(t Task) Task

type TaskOption added in v1.2.0

type TaskOption func(*taskOption)

func WithCallbacks added in v1.2.0

func WithCallbacks(callbacks ...Callback) TaskOption

func WithDescription added in v1.2.0

func WithDescription(description string) TaskOption

func WithMeta added in v1.2.0

func WithMeta(meta map[string]interface{}) TaskOption

func WithName

func WithName(name string) TaskOption

func WithNowFunc added in v1.2.0

func WithNowFunc(nowFunc func() time.Time) TaskOption

func WithTasks

func WithTasks(tasks ...Task) TaskOption

type Vertex

type Vertex struct {
	Task Task
	//Condition Condition
	Prev []*Vertex
	Next []*Vertex
}

Jump to

Keyboard shortcuts

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