task

package
v2.34.0+incompatible Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CancelFunc

type CancelFunc func(task Task) error

type EndFunc

type EndFunc func(task Task)

type Func

type Func func() (value interface{}, err error)

type Info

type Info struct {
	TaskID  string
	Method  string
	Payload []byte
}

type Manager

type Manager interface {
	GetInfos() ([]Info, error)
	AddInfo(taskInfo Info) error
	RemoveInfo(taskID string) error
}

func NewManager

func NewManager(logger boshlog.Logger, fs boshsys.FileSystem, tasksPath string) Manager

type ManagerProvider

type ManagerProvider interface {
	NewManager(boshlog.Logger, boshsys.FileSystem, string) Manager
}

func NewManagerProvider

func NewManagerProvider() ManagerProvider

type Service

type Service interface {
	// Builds tasks but does not record them in any way
	CreateTask(Func, CancelFunc, EndFunc) (Task, error)
	CreateTaskWithID(string, Func, CancelFunc, EndFunc) Task

	// Records that task to run later
	StartTask(Task)
	FindTaskWithID(string) (Task, bool)
}

func NewAsyncTaskService

func NewAsyncTaskService(uuidGen boshuuid.Generator, logger boshlog.Logger) (service Service)

type State

type State string
const (
	StateRunning State = "running"
	StateDone    State = "done"
	StateFailed  State = "failed"
)

type StateValue

type StateValue struct {
	AgentTaskID string `json:"agent_task_id"`
	State       State  `json:"state"`
}

type Task

type Task struct {
	ID    string
	State State
	Value interface{}
	Error error

	Func       Func
	CancelFunc CancelFunc
	EndFunc    EndFunc
}

func (Task) Cancel

func (t Task) Cancel() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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