core

package module
v0.0.0-...-d804c76 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	InternalPrefix = "~"
	WorkflowCtx    = "~workflow~"
	ProcedureCtx   = "~procedure~"
)
View Source
const (
	NoUse = int64(-1)
	End   = int64(0)
	Start = int64(1)
)
View Source
const (
	Pending    = int64(0)
	Running    = int64(0b1)
	Pause      = int64(0b1 << 1)
	Success    = int64(0b1 << 15)
	NormalMask = int64(0b1<<16 - 1)
	Cancel     = int64(0b1 << 16)
	Timeout    = int64(0b1 << 17)
	Panic      = int64(0b11 << 18)
	Failed     = int64(0b1 << 31)
	// abnormal produce status will cause the cancellation of unexecuted steps during execution
	// abnormal step status will cause the cancellation of unexecuted steps that depend on it
	AbnormalMask = NormalMask << 16
)

Variables

This section is empty.

Functions

func AppendStatus

func AppendStatus(addr *int64, update int64) (change bool)

func CopyProperties

func CopyProperties(src, dst interface{})

func CreateStruct

func CreateStruct[T any](src any) (target T)

func ExplainStatus

func ExplainStatus(status int64) []string

func GetFuncName

func GetFuncName(f interface{}) string

func GetIndex

func GetIndex(value any) string

func IsStatusNormal

func IsStatusNormal(status int64) bool

Types

type Context

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

func (*Context) Get

func (ctx *Context) Get(key string) (any, bool)

func (*Context) GetStepResult

func (ctx *Context) GetStepResult(name string) (any, bool)

func (*Context) Set

func (ctx *Context) Set(key string, value any)

type Feature

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

func (*Feature) GetStatusExplain

func (f *Feature) GetStatusExplain() []string

func (*Feature) IsSuccess

func (f *Feature) IsSuccess() bool

func (*Feature) WaitToDone

func (f *Feature) WaitToDone()

type Procedure

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

func (*Procedure) AddConfig

func (pcd *Procedure) AddConfig(config *ProduceConfig)

func (*Procedure) AddStep

func (pcd *Procedure) AddStep(run func(ctx *Context) (any, error), depends ...any) *Step

func (*Procedure) AddStepWithAlias

func (pcd *Procedure) AddStepWithAlias(alias string, run func(ctx *Context) (any, error), depends ...any) *Step

func (*Procedure) AddWaitAll

func (pcd *Procedure) AddWaitAll(alias string, run func(ctx *Context) (any, error)) *Step

func (*Procedure) AddWaitBefore

func (pcd *Procedure) AddWaitBefore(alias string, run func(ctx *Context) (any, error)) *Step

func (*Procedure) DrawRelation

func (pcd *Procedure) DrawRelation() (procedureName string, depends map[string][]string)

func (*Procedure) Pause

func (pcd *Procedure) Pause()

func (*Procedure) SkipFinishedStep

func (pcd *Procedure) SkipFinishedStep(name string, result any)

func (*Procedure) SupplyCtx

func (pcd *Procedure) SupplyCtx(key string, value any)

func (*Procedure) SupplyCtxByMap

func (pcd *Procedure) SupplyCtxByMap(update map[string]any)

type ProcedureInfo

type ProcedureInfo struct {
	Name    string
	StepMap map[string]*StepInfo
	Ctx     *Context
}

type ProduceConfig

type ProduceConfig struct {
	StepTimeout       time.Duration
	ProcedureTimeout  time.Duration
	StepRetry         int
	PreProcessor      func(stepName string, ctx *Context)
	PostProcessor     func(info *StepInfo)
	CompleteProcessor func(info *ProcedureInfo)
}

type Step

type Step struct {
	Start time.Time
	End   time.Time
	Err   error
	// contains filtered or unexported fields
}

func (*Step) AddConfig

func (step *Step) AddConfig(config *StepConfig)

func (*Step) AddPriority

func (step *Step) AddPriority(priority map[string]any)

type StepConfig

type StepConfig struct {
	Timeout  time.Duration
	MaxRetry int
}

type StepInfo

type StepInfo struct {
	Id     string
	Name   string
	Status int64
	Prev   []string
	Next   []string
	Ctx    *Context
	Config *StepConfig
	Start  time.Time
	End    time.Time
	Err    error
}

type Workflow

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

func NewWorkflow

func NewWorkflow(input map[string]any) *Workflow

func (*Workflow) AddProcedure

func (wf *Workflow) AddProcedure(name string, conf *ProduceConfig) *Procedure

func (*Workflow) AsyncFlow

func (wf *Workflow) AsyncFlow() map[string]*Feature

func (*Workflow) WaitToDone

func (wf *Workflow) WaitToDone() map[string]*Feature

Jump to

Keyboard shortcuts

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