Documentation ¶
Index ¶
- Constants
- Variables
- func LoopDo(ctx ExecuteContext, do func() error, ops ...LoopDoOptionOp) error
- type Action
- type AfterAction
- type BeforeAction
- type DefExecuteContext
- func (e *DefExecuteContext) Context() context.Context
- func (e *DefExecuteContext) GetVar(varName string) (string, bool)
- func (e *DefExecuteContext) IterateVars(iterateFunc utils.KeyValueIterateFunc)
- func (e *DefExecuteContext) ShareData() ShareDataOperator
- func (e *DefExecuteContext) Trace(msg string, opt ...TraceOp)
- func (e *DefExecuteContext) Tracef(msg string, a ...interface{})
- func (e *DefExecuteContext) WithValue(key, value interface{})
- type ExecuteContext
- type LoopDoOption
- type LoopDoOptionOp
- type MockAction
- func (_m *MockAction) Name() string
- func (_m *MockAction) ParameterNew() interface{}
- func (_m *MockAction) RetryBefore(ctx ExecuteContext, params interface{}) error
- func (_m *MockAction) Run(ctx ExecuteContext, params interface{}) error
- func (_m *MockAction) RunAfter(ctx ExecuteContext, params interface{}) error
- func (_m *MockAction) RunBefore(ctx ExecuteContext, params interface{}) error
- type MockExecuteContext
- func (_m *MockExecuteContext) Context() context.Context
- func (_m *MockExecuteContext) GetVar(varName string) (string, bool)
- func (_m *MockExecuteContext) IterateVars(iterateFunc utils.KeyValueIterateFunc)
- func (_m *MockExecuteContext) ShareData() ShareDataOperator
- func (_m *MockExecuteContext) Trace(msg string, opt ...TraceOp)
- func (_m *MockExecuteContext) Tracef(msg string, a ...interface{})
- func (_m *MockExecuteContext) WithValue(key interface{}, value interface{})
- type ParameterAction
- type PersistPriority
- type RetryBeforeAction
- type RunFunc
- type ShareDataOperator
- type TraceOp
- type TraceOption
Constants ¶
const ( // Patch change immediately, this will increase the burden of storage // the default behavior PersistPriorityImmediately = "Immediately" // Patch change when after execute each action("RunBefore", "Run" or "RunAfter") // this will be high performance, but here is a risk to lost trace when application crashed PersistPriorityAfterAction = "AfterAction" )
Variables ¶
var (
EndLoop = errors.New("end loop")
)
Functions ¶
func LoopDo ¶
func LoopDo(ctx ExecuteContext, do func() error, ops ...LoopDoOptionOp) error
LoopDo help you to complete loop action,for example
LoopDo(ctx, func(){ log.Println("check status") })
Types ¶
type Action ¶
type Action interface { Name() string Run(ctx ExecuteContext, params interface{}) error }
Action is the interface that user action must implement
type AfterAction ¶
type AfterAction interface {
RunAfter(ctx ExecuteContext, params interface{}) error
}
AfterAction run after run action
type BeforeAction ¶
type BeforeAction interface {
RunBefore(ctx ExecuteContext, params interface{}) error
}
BeforeAction run before run action
type DefExecuteContext ¶
type DefExecuteContext struct {
// contains filtered or unexported fields
}
Default Executor context
func NewDefExecuteContext ¶
func NewDefExecuteContext( ctx context.Context, op ShareDataOperator, trace func(msg string, opt ...TraceOp), dagVars utils.KeyValueGetter, varsIterator utils.KeyValueIterator, ) *DefExecuteContext
NewDefExecuteContext
func (*DefExecuteContext) GetVar ¶
func (e *DefExecuteContext) GetVar(varName string) (string, bool)
GetVar used to get key from ShareData
func (*DefExecuteContext) IterateVars ¶
func (e *DefExecuteContext) IterateVars(iterateFunc utils.KeyValueIterateFunc)
IterateVars used to iterate ShareData
func (*DefExecuteContext) ShareData ¶
func (e *DefExecuteContext) ShareData() ShareDataOperator
ShareData
func (*DefExecuteContext) Trace ¶
func (e *DefExecuteContext) Trace(msg string, opt ...TraceOp)
Trace print msg to the TaskInstance.Traces.
func (*DefExecuteContext) Tracef ¶
func (e *DefExecuteContext) Tracef(msg string, a ...interface{})
Tracef print msg to the TaskInstance.Traces. Arguments are handled in the manner of fmt.Printf. Opt can only be placed at the end of args. Tracef("{format_str}",{format_val},{opts}) e.g. Tracef("%d", 1, TraceOpPersistAfterAction) wrong case: Tracef("%d", TraceOpPersistAfterAction, 1)
func (*DefExecuteContext) WithValue ¶
func (e *DefExecuteContext) WithValue(key, value interface{})
WithValue is wrapper of "context.WithValue"
type ExecuteContext ¶
type ExecuteContext interface { Context() context.Context // WithValue can attach value to context,so can share data between action // however it is base on memory, it is possible to lose changes such as application crash WithValue(key, value interface{}) // Trace print msg to the TaskInstance.Traces. Trace(msg string, opt ...TraceOp) // Tracef print msg to the TaskInstance.Traces. // Arguments are handled in the manner of fmt.Printf. // Opt can only be placed at the end of args. // Tracef("{format_str}",{format_val},{opts}) // e.g. Tracef("%d", 1, TraceOpPersistAfterAction) // wrong case: Tracef("%d", TraceOpPersistAfterAction, 1) Tracef(msg string, a ...interface{}) GetVar(varName string) (string, bool) IterateVars(iterateFunc utils.KeyValueIterateFunc) }
ExecuteContext is a context using by action
type LoopDoOption ¶
type LoopDoOption struct {
// contains filtered or unexported fields
}
LoopDoOption
type LoopDoOptionOp ¶
type LoopDoOptionOp func(loop *LoopDoOption)
func LoopInterval ¶
func LoopInterval(duration time.Duration) LoopDoOptionOp
LoopInterval indicate the interval of loop
type MockAction ¶
MockAction is an autogenerated mock type for the Action type
func (*MockAction) Name ¶
func (_m *MockAction) Name() string
Name provides a mock function with given fields:
func (*MockAction) ParameterNew ¶
func (_m *MockAction) ParameterNew() interface{}
ParameterNew provides a mock function with given fields:
func (*MockAction) RetryBefore ¶
func (_m *MockAction) RetryBefore(ctx ExecuteContext, params interface{}) error
RetryBefore provides a mock function with given fields: ctx, params
func (*MockAction) Run ¶
func (_m *MockAction) Run(ctx ExecuteContext, params interface{}) error
Run provides a mock function with given fields: ctx, params
func (*MockAction) RunAfter ¶
func (_m *MockAction) RunAfter(ctx ExecuteContext, params interface{}) error
RunAfter provides a mock function with given fields: ctx, params
func (*MockAction) RunBefore ¶
func (_m *MockAction) RunBefore(ctx ExecuteContext, params interface{}) error
RunBefore provides a mock function with given fields: ctx, params
type MockExecuteContext ¶
MockExecuteContext is an autogenerated mock type for the ExecuteContext type
func (*MockExecuteContext) Context ¶
func (_m *MockExecuteContext) Context() context.Context
Context provides a mock function with given fields:
func (*MockExecuteContext) GetVar ¶
func (_m *MockExecuteContext) GetVar(varName string) (string, bool)
GetVar provides a mock function with given fields: varName
func (*MockExecuteContext) IterateVars ¶
func (_m *MockExecuteContext) IterateVars(iterateFunc utils.KeyValueIterateFunc)
IterateVars provides a mock function with given fields: iterateFunc
func (*MockExecuteContext) ShareData ¶
func (_m *MockExecuteContext) ShareData() ShareDataOperator
ShareData provides a mock function with given fields:
func (*MockExecuteContext) Trace ¶
func (_m *MockExecuteContext) Trace(msg string, opt ...TraceOp)
Trace provides a mock function with given fields: msg, opt
func (*MockExecuteContext) Tracef ¶
func (_m *MockExecuteContext) Tracef(msg string, a ...interface{})
Tracef provides a mock function with given fields: msg, a
func (*MockExecuteContext) WithValue ¶
func (_m *MockExecuteContext) WithValue(key interface{}, value interface{})
WithValue provides a mock function with given fields: key, value
type ParameterAction ¶
type ParameterAction interface {
ParameterNew() interface{}
}
ParameterAction means action has parameter
type RetryBeforeAction ¶
type RetryBeforeAction interface {
RetryBefore(ctx ExecuteContext, params interface{}) error
}
RetryBeforeAction execute before retry
type RunFunc ¶
type RunFunc func(ctx ExecuteContext, params interface{}) error
RunFunc is task concrete action
type ShareDataOperator ¶
type ShareDataOperator interface {}
ShareDataOperator used to operate share data
type TraceOp ¶
type TraceOp func(opt *TraceOption)
var ( // TraceOpPersistAfterAction // Patch change when after execute each action("RunBefore", "Run" or "RunAfter") // this will be high performance, but here is a risk to lost trace when application crashed TraceOpPersistAfterAction TraceOp = func(opt *TraceOption) { opt.Priority = PersistPriorityAfterAction } )