action

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2015 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Noop = ActionFunc(func() error { return nil })

Functions

func RollbackOnError added in v0.8.0

func RollbackOnError(err *error, action Action)

RollbackOnError is supposed to be used together with defer:

defer action.RollbackOnError(&err, action)

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.

func RollbackTaskOnError added in v0.8.0

func RollbackTaskOnError(err *error, task string, action Action)

RollbackTaskOnError does the same thing as RollbackOnError, but it also informs the user that the given task is being reverted.

Types

type Action

type Action interface {
	Rollback() error
}

type ActionFunc

type ActionFunc func() error

func (ActionFunc) Rollback

func (action ActionFunc) Rollback() error

Jump to

Keyboard shortcuts

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