workflow

package module
v0.0.0-...-4fd31d3 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 1 Imported by: 0

README

workflow

Installation

go get github.com/iTrellis/workflow

Usage

Sample

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context map[string]interface{}

Context 上下文

func (Context) GetContextBool

func (p Context) GetContextBool(key string) (bool, error)

GetContextBool get a bool value by key from context

func (Context) GetContextInt

func (p Context) GetContextInt(key string) (val int, err error)

GetContextInt get a int value by key from context

func (Context) GetContextInterface

func (p Context) GetContextInterface(key string) (interface{}, error)

GetContextInterface get context value

func (Context) GetContextString

func (p Context) GetContextString(key string) (val string, err error)

GetContextString get a string value by key from context

type FailureFunc

type FailureFunc func(err error, step *Step, context Context) error

FailureFunc 错误后执行函数

type Step

type Step struct {
	Label     string
	Run       StepFunc
	IsLast    bool
	DependsOn []*Step
}

Step step to do something

type StepFunc

type StepFunc func(context Context) error

StepFunc step function 执行函数

type Workflow

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

Workflow work flow

func New

func New() *Workflow

New 生成workflow对象

func NewWithFailedFunc

func NewWithFailedFunc(fun FailureFunc) *Workflow

NewWithFailedFunc 生成包含错误执行方法的工作流对象

func (*Workflow) Run

func (p *Workflow) Run(context Context) error

Run 启动工作流

func (*Workflow) SetFailureFunc

func (p *Workflow) SetFailureFunc(fun FailureFunc) *Workflow

SetFailureFunc set failure function 设置错误后的执行方法

func (*Workflow) SetLastStepConcurrency

func (p *Workflow) SetLastStepConcurrency(c bool) *Workflow

SetLastStepConcurrency set the return flag if running before last step 在最后一步之前是否直接返回

func (*Workflow) SetStartStep

func (p *Workflow) SetStartStep(s *Step) *Workflow

SetStartStep set start step 设置第一个启动函数

Jump to

Keyboard shortcuts

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