taskflow

package module
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

README

taskflow

        graph TD
        second --> |SUCCESS|finish
        second --> |FAILURE|failure
        second --> |JUMP2|jump
        failure --> |JUMP3|jump
        failure --> |SUCCESS|finish
        jump --> |SUCCESS|finish
        first --> |SUCCESS|second
        first --> |FAILURE|failure
        first --> |JUMP1|jump
        style finish fill:#f9f

Documentation

Index

Constants

View Source
const (
	StepCodeFailure = "FAILURE"

	StepCodeSuccess = "SUCCESS"

	StepCodeJump1 = "JUMP1"
	StepCodeJump2 = "JUMP2"
	StepCodeJump3 = "JUMP3"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GraphConfig added in v1.2.0

type GraphConfig struct {
	FinishStepKey string

	StartStyleColor   string
	FinishStyleColor  string
	RunStepStyleColor string
}

type RunStep added in v1.2.0

type RunStep struct {
	StepKey  string
	StepCode string
}

type Runner

type Runner[T pcontext.Context] struct {
	GraphConfig *GraphConfig
	// contains filtered or unexported fields
}

func NewRunner

func NewRunner[T pcontext.Context]() *Runner[T]

func (*Runner[T]) RunTask

func (r *Runner[T]) RunTask(ctx T, task Task[T], in, out interface{}) error

func (*Runner[T]) SetStartTraceFunc

func (r *Runner[T]) SetStartTraceFunc(f ptrace.StartTraceFunc[T]) *Runner[T]

func (*Runner[T]) TaskGraph

func (r *Runner[T]) TaskGraph(task Task[T], showCodes ...string) string

func (*Runner[T]) TaskGraphRunSteps added in v1.2.0

func (r *Runner[T]) TaskGraphRunSteps(task Task[T], runSteps []*RunStep, showCodes ...string) string

func (*Runner[T]) TaskGraphRunStepsFromJson added in v1.2.0

func (r *Runner[T]) TaskGraphRunStepsFromJson(task Task[T], runStepsJson []byte, showCodes ...string) (string, error)

func (*Runner[T]) TaskRunSteps added in v1.2.0

func (r *Runner[T]) TaskRunSteps() []*RunStep

type StepConfig

type StepConfig[T pcontext.Context] struct {
	RetryCnt   int
	RetryDelay time.Duration

	StepFunc       StepFunc[T]
	StepFailedFunc StepFailedFunc
	RouteMap       map[string]string
}

type StepFailedFunc

type StepFailedFunc func(stepKey string, err error)

type StepFunc

type StepFunc[T pcontext.Context] func(ctx T) (code string, err error)

type Task

type Task[T pcontext.Context] interface {
	Name() string

	Init(in, out interface{}) error

	StepConfigMap() map[string]*StepConfig[T]
	FirstStepKey() string

	BeforeStep(stepKey string)
	AfterStep(stepKey string)

	Error() error
}

Jump to

Keyboard shortcuts

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