task

package module
v0.0.0-...-ff09f14 Latest Latest
Warning

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

Go to latest
Published: May 20, 2016 License: Apache-2.0 Imports: 3 Imported by: 0

README

Task

Build Status Go Report Card

task is a simple Go library to execute tasks after each other. When one of the tasks fails the queue will be walked backwards and each task gets the opportunity to run rollback actions of the actions performed beforehand.

Installation

To install, simply execute:

go get github.com/denderello/task

Example

You can find a simple example in examples/bool_tasks.go which you can run like this:

go run examples/bool_tasks.go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue

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

func NewQueue

func NewQueue(tasks []Task) *Queue

func (*Queue) Start

func (q *Queue) Start() error

type QueueExecutionError

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

func (*QueueExecutionError) Error

func (e *QueueExecutionError) Error() string

type Task

type Task interface {
	Name() string
	Run() error
	Rollback() error
}

type TaskRecorder

type TaskRecorder struct {
	TaskName           string
	RunSuccessful      bool
	RunExecuted        bool
	RollbackSuccessful bool
	RollbackExecuted   bool
}

func NewTaskRecorder

func NewTaskRecorder(taskName string, runSuccessful, rollbackSuccessful bool) *TaskRecorder

func (*TaskRecorder) Name

func (t *TaskRecorder) Name() string

func (*TaskRecorder) Rollback

func (t *TaskRecorder) Rollback() error

func (*TaskRecorder) Run

func (t *TaskRecorder) Run() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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