Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RevertFunc ¶
type RevertFunc func() error
RevertFunc describes a function used to revert an operation
type Reverter ¶
type Reverter struct {
// contains filtered or unexported fields
}
Reverter provides functionality to automatically revert a set of executed operations. It can be used this way:
r := reverter.New() defer r.Finish()
doOperation()
r.Add(func() error { revertOperation() return nil })
if err := doOtherOperation(); err != nil { return err }
r.Defuse()
func (*Reverter) Add ¶
func (r *Reverter) Add(f ...RevertFunc)
Add adds a new revert function to the reverter which will be called when Finish() is called unless the reverter gets defused.
Click to show internal directories.
Click to hide internal directories.