Documentation ¶
Overview ¶
Package taskflow offers task flow operations
Index ¶
- type Task
- type TaskFlow
- func (p *TaskFlow) AddTask(name string, run TaskRunFunc, revert TaskRevertFunc)
- func (p *TaskFlow) AddTaskWithOutRevert(run TaskWithoutRevert) *TaskFlow
- func (p *TaskFlow) GetResult() map[string]interface{}
- func (p *TaskFlow) Revert()
- func (p *TaskFlow) Run(params map[string]interface{}) (map[string]interface{}, error)
- func (p *TaskFlow) RunWithOutRevert(params map[string]interface{}) error
- type TaskRevertFunc
- type TaskRunFunc
- type TaskWithoutRevert
- type Transaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TaskFlow ¶
type TaskFlow struct {
// contains filtered or unexported fields
}
TaskFlow defines the task flow
func NewTaskFlow ¶
NewTaskFlow create a task flow
func (*TaskFlow) AddTask ¶
func (p *TaskFlow) AddTask(name string, run TaskRunFunc, revert TaskRevertFunc)
AddTask add a task to task flow
func (*TaskFlow) AddTaskWithOutRevert ¶
func (p *TaskFlow) AddTaskWithOutRevert(run TaskWithoutRevert) *TaskFlow
AddTaskWithOutRevert be used when the task does not need revert function
func (*TaskFlow) Revert ¶
func (p *TaskFlow) Revert()
Revert revert tasks in the task flow with revert function
func (*TaskFlow) RunWithOutRevert ¶
RunWithOutRevert run task without revert function and return only error
type TaskRevertFunc ¶
TaskRevertFunc revert task
type TaskRunFunc ¶
type TaskRunFunc func(ctx context.Context, params map[string]interface{}, result map[string]interface{}) (map[string]interface{}, error)
TaskRunFunc run task
type TaskWithoutRevert ¶
TaskWithoutRevert run task without revert
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction implements a TCC (Try Confirm Cancel) pattern.
func NewTransaction ¶
func NewTransaction() *Transaction
NewTransaction instantiate a new transaction.
func (*Transaction) Commit ¶
func (t *Transaction) Commit() error
Commit executes the Transaction steps and returns error if any one step returns error.
func (*Transaction) Rollback ¶
func (t *Transaction) Rollback()
Rollback executes the Transaction rollbacks.
func (*Transaction) Then ¶
func (t *Transaction) Then(exec func() error, onRollback func()) *Transaction
Then adds a step to the steps chain, and returns the same Transaction,