Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrRollbackFailed = errs.NewError( "Roll back changes", errors.New("failed to roll back changes"))
View Source
var Noop = ActionFunc(func() error { return nil })
Functions ¶
func RollbackOnError ¶ added in v0.8.0
RollbackOnError is equivalent to RollbackTaskOnError(err, "", action).
func RollbackTaskOnError ¶ added in v0.8.0
RollbackTaskOnError wraps an ActionChain to perform a rollback on error.
Types ¶
type ActionChain ¶ added in v0.9.0
type ActionChain struct {
// contains filtered or unexported fields
}
func NewActionChain ¶ added in v0.9.0
func NewActionChain() *ActionChain
func (*ActionChain) Push ¶ added in v0.9.0
func (chain *ActionChain) Push(action Action)
func (*ActionChain) PushTask ¶ added in v0.9.0
func (chain *ActionChain) PushTask(task string, action Action)
func (*ActionChain) Rollback ¶ added in v0.9.0
func (chain *ActionChain) Rollback() error
func (*ActionChain) RollbackOnError ¶ added in v0.9.0
func (chain *ActionChain) RollbackOnError(err *error)
RollbackOnError is supposed to be called using defer:
defer chain.RollbackOnError(&err)
Then it is visible why *error is being passed in. The args are bound when this line is encountered, so it would not be set to a non-nil error in case the error is set later. That is why we pass a pointer so that err can be checked when the deferred function is actually called.
type ActionFunc ¶
type ActionFunc func() error
func (ActionFunc) Rollback ¶
func (action ActionFunc) Rollback() error
Click to show internal directories.
Click to hide internal directories.