action

package
v0.4.31 Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Rollback

func Rollback(actions []Action) error

Types

type Action

type Action interface {
	// Execute executes this action, returning error if any.
	Execute(ctx context.Context) error
	// Rollback rollbacks this action, returning error if any.
	Rollback() error
}

Action is an abstraction of some action that can be rolled back.

type ActionQueue

type ActionQueue struct {
	// contains filtered or unexported fields
}

ActionQueue represents a queue of executable actions. Any action that fails triggers cascade previous actions rollback.

func NewActionQueue

func NewActionQueue(actions ...Action) *ActionQueue

func (*ActionQueue) Execute

func (m *ActionQueue) Execute(ctx context.Context) (error, error)

Execute executes the action queue.

If any of actions fails a cascade previous actions rollback occurs resulting in a tuple of this's action error and rollback ones if any.

Jump to

Keyboard shortcuts

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