dtask

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultFactory = map[string]any{
	"declare":  MakeDeclare,
	"return":   MakeReturn,
	"continue": MakeContinue,
	"break":    MakeBreak,
	"printf":   MakePrintf,
	"print":    MakePrint,
	"sleep":    MakeSleep,
	"add":      MakeAdd,
}

Functions

This section is empty.

Types

type Action

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

func (*Action) GetNext

func (action *Action) GetNext(k interface{}) IExecutor

func (*Action) GetScriptLines

func (action *Action) GetScriptLines() []ScriptLine

func (*Action) GetState

func (action *Action) GetState() ExecutorState

func (*Action) Run

func (action *Action) Run(ctx context.Context, signalControl chan ActionControl, varPool VarPool) ([]interface{}, error)

func (*Action) SetNext

func (action *Action) SetNext(k interface{}, exec IExecutor)

type ActionAdd

type ActionAdd struct {
	*BFeedbackReporter
	// contains filtered or unexported fields
}

func (*ActionAdd) Continue

func (s *ActionAdd) Continue() error

func (*ActionAdd) Pause

func (s *ActionAdd) Pause() error

func (*ActionAdd) Start

func (s *ActionAdd) Start() error

func (*ActionAdd) Stop

func (s *ActionAdd) Stop() error

type ActionBreak

type ActionBreak struct {
	*BFeedbackReporter
}

func (*ActionBreak) Continue

func (s *ActionBreak) Continue() error

func (*ActionBreak) Pause

func (s *ActionBreak) Pause() error

func (*ActionBreak) Start

func (s *ActionBreak) Start() error

func (*ActionBreak) Stop

func (s *ActionBreak) Stop() error

type ActionContinue

type ActionContinue struct {
	*BFeedbackReporter
}

func (*ActionContinue) Continue

func (s *ActionContinue) Continue() error

func (*ActionContinue) Pause

func (s *ActionContinue) Pause() error

func (*ActionContinue) Start

func (s *ActionContinue) Start() error

func (*ActionContinue) Stop

func (s *ActionContinue) Stop() error

type ActionControl

type ActionControl uint8
const (
	ActionControlPause ActionControl = iota + 1
	ActionControlContinue
	ActionControlStop
)

func (ActionControl) String

func (t ActionControl) String() string

type ActionDeclare

type ActionDeclare struct {
	*BFeedbackReporter
	// contains filtered or unexported fields
}

func (*ActionDeclare) Continue

func (s *ActionDeclare) Continue() error

func (*ActionDeclare) Pause

func (s *ActionDeclare) Pause() error

func (*ActionDeclare) Start

func (s *ActionDeclare) Start() error

func (*ActionDeclare) Stop

func (s *ActionDeclare) Stop() error

type ActionJson

type ActionJson struct {
	Inputs  []interface{} `json:"inputs"`
	Outputs []string      `json:"outputs"`
	IsGo    bool          `json:"is_go"`
}

type ActionPrint

type ActionPrint struct {
	*BFeedbackReporter
	// contains filtered or unexported fields
}

func (*ActionPrint) Continue

func (s *ActionPrint) Continue() error

func (*ActionPrint) Pause

func (s *ActionPrint) Pause() error

func (*ActionPrint) Start

func (s *ActionPrint) Start() error

func (*ActionPrint) Stop

func (s *ActionPrint) Stop() error

type ActionPrintf

type ActionPrintf struct {
	*BFeedbackReporter
	// contains filtered or unexported fields
}

func (*ActionPrintf) Continue

func (s *ActionPrintf) Continue() error

func (*ActionPrintf) Pause

func (s *ActionPrintf) Pause() error

func (*ActionPrintf) Start

func (s *ActionPrintf) Start() error

func (*ActionPrintf) Stop

func (s *ActionPrintf) Stop() error

type ActionReturn

type ActionReturn struct {
	*BFeedbackReporter
}

func (*ActionReturn) Continue

func (s *ActionReturn) Continue() error

func (*ActionReturn) Pause

func (s *ActionReturn) Pause() error

func (*ActionReturn) Start

func (s *ActionReturn) Start() error

func (*ActionReturn) Stop

func (s *ActionReturn) Stop() error

type ActionSleep

type ActionSleep struct {
	*BFeedbackReporter
	// contains filtered or unexported fields
}

func (*ActionSleep) Continue

func (s *ActionSleep) Continue() error

func (*ActionSleep) Pause

func (s *ActionSleep) Pause() error

func (*ActionSleep) Start

func (s *ActionSleep) Start() error

func (*ActionSleep) Stop

func (s *ActionSleep) Stop() error

type ActionTree

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

func (ActionTree) GetScriptLines

func (tree ActionTree) GetScriptLines() []ScriptLine

func (ActionTree) String

func (tree ActionTree) String() string

type BFeedbackReporter

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

func (BFeedbackReporter) Complete

func (r BFeedbackReporter) Complete(returns ...interface{})

func (BFeedbackReporter) Feedback

func (r BFeedbackReporter) Feedback(t FeedbackType, returns []interface{}, err error)

func (BFeedbackReporter) FeedbackNoContent

func (r BFeedbackReporter) FeedbackNoContent(t FeedbackType)

type ExecutorState

type ExecutorState uint8
const (
	ExecutorStateIdle       ExecutorState = iota //空闲
	ExecutorStateRunning                         //运行中
	ExecutorStatePausing                         //暂停中
	ExecutorStatePaused                          //已暂停
	ExecutorStateContinuing                      //继续中
	ExecutorStateStopping                        //停止中
	ExecutorStateStopped                         //停止中
	ExecutorStateComplete                        //执行完成
	ExecutorStateError                           //出粗
)

func (ExecutorState) String

func (state ExecutorState) String() string

type ExprJson

type ExprJson struct {
	Condition interface{}                `json:"condition" binding:"required"`
	SubSteps  map[string][]StatementJson `json:"sub_steps" binding:"required"`
}

type Expression

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

func (*Expression) Do

func (expr *Expression) Do(varPool VarPool) (interface{}, bool, error)

func (*Expression) GetNext

func (expr *Expression) GetNext(k interface{}) IExecutor

func (*Expression) GetScriptLines

func (expr *Expression) GetScriptLines() []ScriptLine

func (*Expression) GetState

func (expr *Expression) GetState() ExecutorState

func (*Expression) SetNext

func (expr *Expression) SetNext(k interface{}, exec IExecutor)

type Feedback

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

type FeedbackType

type FeedbackType uint8
const (
	FBStartSuccess    FeedbackType = iota //启动成功
	FBPauseSuccess                        //暂停成功
	FBContinueSuccess                     //继续成功
	FBStopSuccess                         //停止成功
	FBComplete                            //运行完成
	FBRunningError                        //运行出错
)

func (FeedbackType) String

func (t FeedbackType) String() string

type IAction

type IAction interface {
	Start() error
	Pause() error
	Continue() error
	Stop() error
}

func MakeAdd

func MakeAdd(reporter *BFeedbackReporter, x, y int) (IAction, error)

func MakeBreak

func MakeBreak(reporter *BFeedbackReporter) (IAction, error)

func MakeContinue

func MakeContinue(reporter *BFeedbackReporter) (IAction, error)

func MakeDeclare

func MakeDeclare(reporter *BFeedbackReporter, value interface{}) (IAction, error)

func MakePrint

func MakePrint(reporter *BFeedbackReporter, args []interface{}) (IAction, error)

func MakePrintf

func MakePrintf(reporter *BFeedbackReporter, format string, args []interface{}) (IAction, error)

func MakeReturn

func MakeReturn(reporter *BFeedbackReporter) (IAction, error)

func MakeSleep

func MakeSleep(reporter *BFeedbackReporter, seconds float64) (IAction, error)

type ICycleExpr

type ICycleExpr interface {
	CycleExpr()
}

type IExecutor

type IExecutor interface {
	SetNext(k interface{}, exec IExecutor)
	GetNext(k interface{}) IExecutor
	GetState() ExecutorState
	GetScriptLines() []ScriptLine
}

type IExpr

type IExpr interface {
	Expr(condition interface{}) (interface{}, error)
}

type Inputs

type Inputs []interface{}

func (Inputs) String

func (inputs Inputs) String() string

type Outputs

type Outputs []string

func (Outputs) String

func (outputs Outputs) String() string

type Parser

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

func NewParser

func NewParser(factory map[string]any) *Parser

func (Parser) Parse

func (p Parser) Parse(data []byte) (*ActionTree, error)

type ScriptLine

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

type StatementJson

type StatementJson struct {
	Name   string        `json:"name" binding:"required"`
	Type   StatementType `json:"type"`
	Retry  int           `json:"retry"`
	Params djson.Raw     `json:"params" binding:"required"`
}

type StatementType

type StatementType uint8
const (
	StatementAction StatementType = iota
	StatementExpr
)

type TaskJson

type TaskJson struct {
	Name       string          `json:"name" binding:"required"`
	Statements []StatementJson `json:"statements" binding:"required"`
}

type TaskRunner

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

func NewRunner

func NewRunner(actionTree *ActionTree) *TaskRunner

func (*TaskRunner) Continue

func (runner *TaskRunner) Continue() error

func (*TaskRunner) GetScript

func (runner *TaskRunner) GetScript() string

func (*TaskRunner) Pause

func (runner *TaskRunner) Pause() error

func (*TaskRunner) Print

func (runner *TaskRunner) Print()

func (*TaskRunner) Start

func (runner *TaskRunner) Start() error

func (*TaskRunner) Stop

func (runner *TaskRunner) Stop() error

type VarPool

type VarPool map[string]interface{}

func (*VarPool) Add

func (pool *VarPool) Add(key string, value interface{})

func (*VarPool) MakeInput

func (pool *VarPool) MakeInput(inputs ...interface{}) ([]interface{}, error)

func (*VarPool) Merge

func (pool *VarPool) Merge(another VarPool)

func (*VarPool) SaveOutputs

func (pool *VarPool) SaveOutputs(keys []string, value ...interface{}) error

func (*VarPool) String

func (pool *VarPool) String() string

func (*VarPool) Summary

func (pool *VarPool) Summary(another VarPool)

Jump to

Keyboard shortcuts

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