taskman

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

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

Go to latest
Published: Feb 6, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

README

go-taskman

Build Status GoDoc Go Report Card

Run "tasks" in the background

Install

go get -v github.com/bryanjeal/go-taskman

Help

cd <path>/github.com/bryanjeal/go-taskman Make help

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidName   = errors.New("name cannot be blank or all spaces")
	ErrAlreadyExists = errors.New("task with that name already exists")
	ErrTaskNotFound  = errors.New("task with supplied name not found")
	ErrNotActive     = errors.New("task manager has been shutdown")
)

Errors

Functions

This section is empty.

Types

type Service

type Service interface {
	// New adds a stored task to the manager
	New(name string, taskFunc TaskRunFunc) error

	// Check takes a task name and checks to see if there are any errors from that task
	Check(name string) []error

	// Run takes a task name and runs it with supplied args
	Run(name string, args ...interface{}) (chan error, error)

	// RunTask takes a Task and queues it to run
	RunTask(task Task) (string, chan error, error)

	// Shutdown stops the service
	Shutdown() error
}

Service is the interface that provides auth methods.

type Task

type Task struct {
	Name    string
	Func    TaskRunFunc
	Errs    []error
	ErrChan chan error
	Quit    chan struct{}
}

Task model represents each task in the system

type TaskManager

type TaskManager struct {
	*sync.RWMutex
	// contains filtered or unexported fields
}

TaskManager is the core of the taskman service it is responsible for running tasks

func NewTaskManager

func NewTaskManager() (tm *TaskManager)

NewTaskManager initializes a new TaskMan service and returns the instance of it

func (*TaskManager) Check

func (tm *TaskManager) Check(name string) []error

Check takes a task name and checks to see if there are any errors from that task

func (*TaskManager) New

func (tm *TaskManager) New(name string, taskFunc TaskRunFunc) error

New adds a stored task to the manager

func (*TaskManager) Run

func (tm *TaskManager) Run(name string, args ...interface{}) (chan error, error)

Run takes a task name and runs it with supplied args

func (*TaskManager) RunTask

func (tm *TaskManager) RunTask(task Task, args ...interface{}) (string, chan error, error)

RunTask takes a task and runs it

func (*TaskManager) Shutdown

func (tm *TaskManager) Shutdown()

Shutdown stops task processing sends "quit" to all tasks as well (for long running tasks)

type TaskRunFunc

type TaskRunFunc func(args ...interface{}) error

TaskRunFunc is the function that is run

Jump to

Keyboard shortcuts

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